All Questions
Tagged with c# unity-game-engine
43,296
questions
374
votes
37
answers
552k
views
Unity Scripts edited in Visual studio don't provide autocomplete
When I want to edit C# Unity scripts, they open in Visual Studio. It is supposed to provide auto complete for all Unity related code, but it doesn't work.
Here you can see the missing functionality:
...
158
votes
8
answers
93k
views
How does StartCoroutine / yield return pattern really work in Unity?
I understand the principle of coroutines. I know how to get the standard StartCoroutine / yield return pattern to work in C# in Unity, e.g. invoke a method returning IEnumerator via StartCoroutine ...
144
votes
11
answers
288k
views
Serialize and Deserialize Json and Json Array in Unity
I have a list of items send from a PHP file to unity using WWW.
The WWW.text looks like:
[
{
"playerId": "1",
"playerLoc": "Powai"
},
{
"playerId": "2",
"...
113
votes
4
answers
155k
views
How to detect click/touch events on UI and GameObjects
How to detect UI object on Canvas on Touch in android?
For example, I have a canvas that have 5 objects such as Image, RawImage, Buttons, InputField and so on.
When I touch on Button UI object Then ...
103
votes
11
answers
439k
views
How to make the script wait/sleep in a simple way in unity
How can I put a sleep function between the TextUI.text = ...., to wait 3 seconds between each phrase?
public Text GuessUI;
public Text TextUI;
[...truncated...]
TextUI.text = "Welcome to Number ...
99
votes
6
answers
194k
views
How to pass data (and references) between scenes in Unity
How can I pass score value from one scene to another?
I've tried the following:
Scene one:
void Start () {
score = 0;
updateScoreView ();
StartCoroutine (DelayLoadlevel(20));
}
public ...
99
votes
1
answer
6k
views
Marching Cubes - generating holes in mesh
I'm working on a Marching Cubes implementation in Unity. My code is based on Paul Bourke's code with a lot of modifications. I'm checking if a block at a position is null, and if it is, a debug ...
91
votes
1
answer
372k
views
"A namespace cannot directly contain members such as fields or methods" [closed]
I am trying to use this code for NET.reflector using Reflexil. I am trying to replace code with this:
if(Input.GetKeyDown(KeyCode.Keypad5)) {
int i = 0;
Character localPlayer = PlayerClient....
83
votes
1
answer
3k
views
How to resolve SmartFoxServer connection error in unity
I'm using SmartFoxServer API on Unity3d. It was working fine before I recovered my MacBook, but now gives a connection error as below:
Http error creating http connection: System.Net.Sockets....
67
votes
4
answers
36k
views
How to set up unit tests in Unity and fix missing assembly reference error?
I created the following structure:
├── Assets
├── Scenes
├── Scripts
│ └── MyExample.cs
├── Tests
│ ├── MyExampleTest.cs
│ └── Tests.asmdef
Now, when I click on Run All, in the Test Runner ...
62
votes
5
answers
76k
views
Unity game manager. Script works only one time
I'm making simple game manager. I have a script, which will be accessible from all scenes in the game. And I need to check values of its variables after loading new scene. But my code runs only once ...
56
votes
14
answers
85k
views
How to get intellisense in Visual Studio Code for Unity functions names?
I am following a tutorial about Unity and I see that the instructor has intellisense when writes the method's name.
However I have only intellisense with classes and variables, I mean Unity classes ...
56
votes
2
answers
53k
views
Why should I use SerializeField?
I have just started to learn C# and Unity, and there is one thing that I can not get used to:
Why and when should I use [SerializeField]?
Is it bad to leave variables hard coded despite using [...
55
votes
3
answers
38k
views
Why choose UnityEvent over native C# events?
I mean, UnityEvents are slower than the native C# events and they still store a strong reference to the receivers. So, the only valid reason I can find to use UnityEvents over native C# events is ...
55
votes
5
answers
2k
views
Is it possible to simplify an if-statement that checks for a combination?
I'm currently working on adding sound effects to a game, and although my current code is working fine, I'm looking for a way to simplify it.
Basically, each object in the game has a string value ...