Skip to main content

All Questions

Tagged with
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", "...
dil33pm's user avatar
  • 1,613
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 ...
Dennis Liu's user avatar
  • 2,318
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 ...
Mina Fawzy's user avatar
  • 21.3k
17 votes
2 answers
23k views

What is the best way to save game state?

I find the best way to save game data in Unity3D Game engine. At first, I serialize objects using BinaryFormatter. But I heard this way has some issues and is not suitable for save. So, What is the ...
Sizzling's user avatar
  • 215
53 votes
6 answers
63k views

Use Unity API from another Thread or call a function in the main Thread

My problem is I try to use Unity socket to implement something. Each time, when I get a new message I need to update it to the updattext (it is a Unity Text). However, When I do the following code, ...
user6142261's user avatar
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 ...
DiogoSaraiva's user avatar
  • 1,605
42 votes
4 answers
86k views

Using new Unity VideoPlayer and VideoClip API to play video

MovieTexture is finally deprecated after Unity 5.6.0b1 release and new API that plays video on both Desktop and Mobile devices is now released. VideoPlayer and VideoClip can be used to play video and ...
Programmer's user avatar
  • 124k
19 votes
3 answers
25k views

Using Resources Folder in Unity

I have am developing a HoloLens project that needs to reference .txt files. I have the files stored in Unity's 'Resources' folder and have them working perfectly fine (when run via Unity): string ...
whycodingsohard's user avatar
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: ...
CorbenDalas's user avatar
  • 3,903
9 votes
3 answers
10k views

Move GameObject over time

I am learning Unity from a Swift SpriteKit background where moving a sprite's x Position is as straight forward as an running an action as below: let moveLeft = SKAction.moveToX(self.frame.width/5, ...
Nullititiousness's user avatar
8 votes
2 answers
13k views

Unity: Null while making new class instance

I got stuck in pretty dumb situation: I'm making new instance of the generic class but it returns "weird" null. Rule rule2 = new Rule(); // initiate the class Debug.Log(rule2); //1st debug ...
Alex's user avatar
  • 319
40 votes
4 answers
75k views

Sending http requests in C# with Unity

How can I send HTTP GET and POST requests in C# with Unity? What I want is: send json data in post request (I use Unity serializer, so no need in new one, I just want to pass a string in post data ...
Kamo Spertsian's user avatar
3 votes
4 answers
6k views

Access variables/functions from another Component

So im trying to change a variable in another script by touching a cube. Current setup 1x Player 1x Enemy Each with their own script Enemy_Stats & Character_Stats As you can see in this ...
Simon's user avatar
  • 382
17 votes
3 answers
92k views

How to access a variable from another script in another gameobject through GetComponent?

I've searched around and I just can't get this to work. I think I just don't know the proper syntax, or just doesn't quite grasp the context. I have a BombDrop script that holds a public int. I got ...
DoubleCode's user avatar
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 ...
Amazing User's user avatar
  • 3,503

15 30 50 per page
1
2 3 4 5
141