unity5

Best way to save data in Unity game [closed]

一个人想着一个人 提交于 2019-12-17 22:11:44
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 years ago . I was wondering... What's the best way to save data in Unity games. JSONs? If so, how? Thanks 回答1: Short answer to your long question! Here are some of the different Ways and Methods to Save data for Unity Projects: Platform-Independent: One way of saving data in Unity3D in a

Objects in Scene dark after calling LoadScene/LoadLevel

风格不统一 提交于 2019-12-17 03:45:47
问题 I completed Unity's roll-a-ball tutorial and it works fine. I changed a couple of materials to make it look better. I also added a C# script that should restart the level when the player falls off of the ground (I disables the walls). I am using Unity 5.5. It initially looks like this: But when I go off the edge and the level restarts, it looks like this: It sometimes looks like this for a few seconds after opening unity when the editor is loading. Here is the script: using UnityEngine; using

How do I use variables in a separate script in Unity3D?

巧了我就是萌 提交于 2019-12-14 03:29:47
问题 Title explains it all, I want to know how to access variables from another script. I've searched online, but found nothing that's worked. 回答1: You could make a class , instantiate an object of the class and access propterties. Or you could use static variables. Or even beter, lets say you have a GameManager.cs script attached to an empty object called GameManager. And you want to access its variables form the LevelManager.cs script. You do this inside the LevelManager.cs public GameManager

How can I access private List<T> members?

╄→尐↘猪︶ㄣ 提交于 2019-12-14 02:48:09
问题 In general, in C# it is more convenient to use List than T[]. However, there are times when the profiler shows that List has significant performance penalties compared to natively-implemented bulk operations like Array.Copy and Buffer.BlockCopy. In addition, it is not possible to get pointers to List<> elements. This makes working with dynamic meshes in Unity somewhat painful. Some of these problems could be alleviated if we could access T[] List._items . Is this possible to do without

Unity: Quiz game multiple choice button colors

本秂侑毒 提交于 2019-12-13 22:15:29
问题 I'm doing a multiple choice quiz game, and im tryinng to highlight the correct answer in green if the wrong answer is clicked. for example if i have A , B , C and D and "A" is the correct answer. i want if i choose "B" to turn B to red color and display the correct answer to green which is in this case "A". Right now i have if i click the right answer it displays green, as i want it. and if i press wrong answer it displays red. what im missing is when i click wrong answer i want to also

Error: Non-invocable member 'Vector2' cannot be used like a method

五迷三道 提交于 2019-12-13 18:50:43
问题 I am trying to do Vector2(-1, 0) instead of Vector2.left but it gives this error: Non-invocable member 'Vector2' cannot be used like a method Any ideas? 回答1: Vector2.Left is equal to new Vector2(-1,0) ; , not Vector2(-1, 0) :) 回答2: I think this happens because you use syntax like this: Vector2 vec; //assign new value vec = Vector2(-1,0); This is not gonna work because compiler thinks that you are using method called Vector2() which doesn't exist and it is not correct because you should create

Properly play Particule System component?

本小妞迷上赌 提交于 2019-12-13 13:23:44
问题 How can I properly play the particle system component, which is attached to a GameObject? I also attached the following script to my GameObject but the Particle System does not play. How do I fix this? public Transform gameobject1; public Transform gameobject2; public ParticleSystem particules; void Start() { float distance = Vector3.Distance(gameobject1.position, gameobject2.position); } void Update() { if(distance == 20) { particules.Play(); } } 回答1: I don't see you declaring distance in

Getting hit after invicibility when standing on trap

浪子不回头ぞ 提交于 2019-12-13 08:10:04
问题 I am working on a simple 2D platformer game in which i have made an knockback effect. When the player gets hit by an obstacle, which currently is just a spike, he has a knockback and temporary invicibility, so when standing on spike during the invicibility he dosen't get hit. However, once the invicibility ends, i want to have player get hit by a spike like in the following GIF. https://media.giphy.com/media/26FeVTRop5PhBrJQs/giphy.gif The player gets hit because the invicibility is gone and

Unity - Error building APK

大兔子大兔子 提交于 2019-12-13 05:51:22
问题 I am very new to the Unity and I am trying solve the problem for 1 week but still can't solve and I decided come here to ask expert. During build apk in Unity I got below error: CommandInvokationFailure: Failed to re-package resources. See the Console for details. C:\Android\android-sdk\build-tools\24.0.0\aapt.exe package --auto-add-overlay -v -f -m -J gen -M AndroidManifest.xml -S "res" -I "C:/Android/android-sdk\platforms\android-24\android.jar" -F bin/resources.ap_ stderr[ ] stdout[ ]

How to make IPointer work on respective box collider?

天涯浪子 提交于 2019-12-13 03:47:39
问题 I tried to implement IPointerEnter , IPointerExit , IPointerDown and IPointerUp . All of them were working fine until they start overlapping. My question is how do I make IPointer... to work on their respective collider? A and B are BoxCollider2D , B is inside of A . Both of them have a script that has above IPointer... implemented. Below are the issues that I am having with this condition. Upon clicking mouse down inside B , only 1 box will trigger the IPointerDown . (This is solved by this