Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options answers only not deleted user 75627

C# is a multi-paradigm, managed, strongly typed, garbage-collected, programming language created by Microsoft in conjunction with the .NET platform.

24 votes
Accepted

Why does Unity use reflection to get the update method?

It doesn't How Update is called No, Unity doesn’t use System.Reflection to find a magic method every time it needs to call one. Instead, the first time a MonoBehaviour of a given type is accessed the …
Draco18s no longer trusts SE's user avatar
11 votes
Accepted

Why does Physics2D.Raycast automatically fail if applying a layer mask?

A Layer Mask is an integer, so that's right. But if you want to test against Layer 8, you don't pass in 8 as the value. What if you want to check against 8 and 7? Well, 15 is the wrong answer there …
Draco18s no longer trusts SE's user avatar
8 votes
Accepted

Expose private methods to inspector?

You can't Private methods can't be exposed to the editor. Your goal her is to have another script invoke the method, and the only way to do that (and in fact the only thing that even makes sense) is f …
Draco18s no longer trusts SE's user avatar
7 votes

Why when getting the waypoints objects in script the order in the array is not the same as i...

The scene hierarchy can be reordered by dragging things around. However the default ordering (the order in which the objects were created) still applies. The GameObject.FindGameObjectsWithTag() metho …
Draco18s no longer trusts SE's user avatar
7 votes

Debug.DrawRay() does not draw rays in game view

Debug.DrawRay (and other such functions) never draw in the game view They're debug drawings and debug info and output should never appear in the "live" program view, which is supposed to mimic the com …
Draco18s no longer trusts SE's user avatar
5 votes
Accepted

Unity: how intercept Mouse Click on UI and not fire "shoot"?

So, first, stop using Input.GetMouseButtonDown(0), use Input.GetButton("Fire1"). This allows your player to remap the controls. It won't fix your problem, but this is still something you should do. O …
Draco18s no longer trusts SE's user avatar
5 votes

Why is the while loop an infinite loop?

Lets step through this: foreach (Transform child in AttackersHolder.transform) child is automatically non-null, therefor child != null evaluates to true. while (true) { //do stuff …
Draco18s no longer trusts SE's user avatar
4 votes
Accepted

Why does the Debug.DrawRay return these weird lines

You're drawing Rays, not Lines. This means that the second parameter is a direction not a point in space. https://docs.unity3d.com/ScriptReference/Debug.DrawRay.html Draws a line from start to st …
Draco18s no longer trusts SE's user avatar
4 votes

How can I locate GameObjects near the player in Unity?

There are a number of ways to get a reference to a GameObject. In your desire to locate objects near the Player, Physics.OverlapSphere() is likely what you are looking for. The various Physics static …
Draco18s no longer trusts SE's user avatar
3 votes

Null Reference Exception while getting Components

You can't reference across a scene boundary If you have two scenes, nothing in scene 1 can reference things in scene 2 and vice versa. When you are in scene 1, scene 2 does not exist and vice versa. Y …
Draco18s no longer trusts SE's user avatar
2 votes

How to access a variable from another C# script in Unity

You can't, it's private. Now, that's not the end of things, as I suspect that wasn't really your question. Firstly, you need a reference to this script. Which you can get from a reference to the game …
Draco18s no longer trusts SE's user avatar
2 votes
Accepted

Unity: Cannot access variable of C# script from another object

This is caused by Unity But it's easy to fix. The Standard Assets folder is compiled before all other scripts (this may be a holdover from when Unity officially supported JavaScript / UnityScript file …
Draco18s no longer trusts SE's user avatar
2 votes

Cannot detect input in void OnCollisionEnter()

Do something like this: var timeSinceCollision = 999; void Update() { timeSinceCollision += Time.deltaTime; if(timeSinceCollision < 0.5 && Input.GetMouseButtonDown(0)) { // do someth …
Draco18s no longer trusts SE's user avatar
2 votes

Unity 3D C# - Shifting beetween worlds?

This is kind of an extension to @jackmott's answer, similar his suggestions, but different. Instead of using GameObject.SetActive() to flip the states of everything in the scene, I would instead sugg …
Draco18s no longer trusts SE's user avatar
2 votes
Accepted

Detect clusters of tokens on an x y grid

Well, finding 3+ is easy if you realize that regardless of their respective positions to each other, at least one of them will always have at least two neighbors. Once you've found a location in the …
Draco18s no longer trusts SE's user avatar

1
2 3 4 5
15 30 50 per page