Questions tagged [unity-game-engine]
Unity is a cross-platform game engine by Unity Technologies. Questions should be about programming with the game engine and not usage of the graphical interface. Questions about the usage of the graphics interface are off topic.
unity-game-engine
76,962
questions
571
votes
18
answers
269k
views
How to use Git for Unity3D source control?
What are best practices for using Git source control with Unity 3D, particularly in dealing with the binary nature of Unity 3D projects? Please describe the workflow, what paths would be included in ....
374
votes
37
answers
551k
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:
...
187
votes
2
answers
138k
views
How to prepare a Unity project for git (step-by-step)? [duplicate]
What are the detailed steps necessary to prepare a Unity project for committing to a git repository eg. github? I don't want to store unnecessary files (specially temp files and avoid binary formats ...
157
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",
"...
128
votes
8
answers
183k
views
what is the difference between Update & FixedUpdate in Unity?
What is the difference between the Update and FixedUpdate methods, and when should these methods be used?
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 ...
102
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 ...
98
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 ...
96
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....
90
votes
5
answers
81k
views
Awake() and Start()
I see that we can initialize Variable in Awake() or Start() and Awake() will be called before Start().
When should we initialize in Awake and Start to have the best performance?
86
votes
11
answers
124k
views
not finding android sdk (Unity)
Error:
Invalid command android
UnityEditor.HostView:OnGUI()
CommandInvokationFailure:
Unable to list target platforms. Please make sure the android sdk path is correct. See the Console for more ...
84
votes
12
answers
143k
views
What Language is Used To Develop Using Unity
What language does one need to use when programming with Unity? Or is it an API for many languages?
I read through the docs and I guess I missed the point on the language used.
It says it has iOS ...
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....
78
votes
6
answers
43k
views
The "GetReferenceNearestTargetFrameworkTask" task was not found
I have a problem with autocompletion in VS 2017 Community.
Previously I had VS 2017 Enterprise from school, but the key expired so I moved to Community.
Before, everything works great, but now it ...
78
votes
4
answers
63k
views
Ignoring folder meta files on version control
Unity creates and deletes meta files for folders inside the Asset folder.
That can create an annoying situation when using version control (that you can skip and go to the questions): someone creates ...
71
votes
11
answers
96k
views
How to Work With Different Screen Resolutions
I'm using Unity 4.3.3 for my game. I'm making a game for Android and iOS devices. Since I'm pretty new to unity, I can't seem to find a way to work with different screen resolution.
I'm using c# for ...
69
votes
1
answer
28k
views
How to build Unity3d Plugin for iOS
I have a very tiny Objective-C library built for iOS and I want to export it to Unity. I understand the basic process of writing a csharp wrapper that marshals all the invocations to native library, ...
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 ...
65
votes
4
answers
85k
views
How to Rename a Unity Project?
I want to change the name of a Unity project to something else such that Unity Editor shows the new name at the top or when I open a script using Visual Studio, it shows the new name at the top of VS. ...
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 ...
58
votes
1
answer
70k
views
Unity Export Android 64-bit
I've been trying to upload .abb to the google play console. When I upload it, it gives me this error:
This release is not compliant with the Google Play 64-bit requirement
The following APKs or App ...
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 ...
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 ...
55
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 [...
54
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 ...
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, ...
53
votes
6
answers
30k
views
How do we manually fix "ResourceRules.plist: cannot read resources" error after xcode 6.1 upgrade?
We are having the same issue found here, here, here and here
Basically we upgraded to xcode 6.1 and our build are getting the "ResourceRules.plist: cannot read resources" error.
We have a Jenkins ...
52
votes
3
answers
34k
views
Unity3d integration with android
I need to create an android application which consists of parts written on Unity3d (animation and so on) and on AndroidSDK (by androidSDK I mean few activities written in java, manifest and resources)
...
51
votes
14
answers
225k
views
Can't add script component because the script class cannot be found?
Yesterday I updated unity from unity5 to 2018.2.2f1. Unity scripts are not loading after Update 2018.2.2f1.
Once I try to play the Scene the scripts are not loaded and I can't add the script again it ...
49
votes
6
answers
131k
views
Can I program in C# on a Mac?
I want to learn C# for Unity and my personal computer is a MacBook Air. Can I program in C# on a Mac?
48
votes
4
answers
21k
views
Understanding scenes in Unity3d
I have some confusion with scenes in Unity3d and I was not able to find any resources about them.
When should scenes be used? For example in a platformer would every level have to be a different ...
48
votes
2
answers
37k
views
Why float.Epsilon and not zero?
In the following code, why is there a comparison against float.Epsilon and not 0?
// Coroutine to move elements
protected IEnumerator SmoothMovement (Vector3 end)
{
// Distance computation
...
47
votes
9
answers
120k
views
NuGet packages in Unity
I want to use some NuGet packages inside Unity. I achieved that Unity finds the downloaded DLLs according to this article (https://www.what-could-possibly-go-wrong.com/unity-and-nuget/). The nuget....
45
votes
9
answers
39k
views
Reference assemblies for framework ".NETFramework,Version=v4.7.1" were not found
I try to open a Unity3D project with VSCode under Linux (Ubuntu 18.10). The omnisharp extension doesn't load the project, saying assemblies were not found.
It may seems very stupide, but i'm not ...
45
votes
4
answers
11k
views
Getting "giggly" effect when slowly moving a sprite
How do I remove this "giggly" effect when slowly moving a sprite?
I have tried adjusting Antialiasing values in QualitySettings and Filter Mode in ImportSettings in the Unity Editor but that doesn't ...
45
votes
1
answer
16k
views
Why is Unity ignoring the initialized value of a non-static public field?
I'm using InvokeRepeating() to call a method in a game. I call InvokeRepeating() in the Start() method of one of the GameObject classes. To set the repeatRate parameter for InvokeRepeating(), I am ...
44
votes
6
answers
76k
views
Unity - How to stop Play Mode in case of infinite loop?
I just made a silly mistake and I ended up with an infinite loop inside my Update(). After that I wasn´t able to stop the Play Mode. Actually I wasn´t able to do anything else with Unity until I ...
43
votes
11
answers
40k
views
APKs or App Bundles are available to 64-bit devices but they only have 32-bit native code
I have exported an Android App Bundle file to upload at Play store with NDK downloaded from Unity desired location because Android Studio NDK file is not compatible with Unity.
I got this kind of ...
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 ...
42
votes
8
answers
37k
views
Working with Unity3D and Visual Studio 2013
how do i get Unity3D for debugging the code, and Visual Studio 2013 which i have now to only script the code. Example: Like Flash Professional for debugging and FlashDevelop for scripting only.
My ...
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 ...
40
votes
4
answers
93k
views
In unity3D, Click = Touch?
I want to detect click/touch event on my gameObject 2D.
And this is my code:
void Update()
{
if (Input.touchCount > 0)
{
Debug.Log("Touch");
}
}
Debug.Log("Touch"); does not show ...
40
votes
21
answers
14k
views
Debugging with unity
At the current moment, what I'm doing is that I'm opening Unity, double click on one of those scripts I've written, then MonoDevelop gets opened, now I have to close unity and in MonoDevelop I do Run &...
39
votes
4
answers
188k
views
How to find child of a GameObject or the script attached to child GameObject via script
I know this is a bit of a stupid question, but how would I reference the child (a cube) of a game object via script(the script is attached to the gameObject). (the equivalent to something like ...
39
votes
10
answers
44k
views
C# game development after XNA [closed]
I am a game developer who made games in .Net languages with XNA for the past four versions of it. Unfortunately now there's this news: http://www.gamasutra.com/view/news/185894/...
38
votes
3
answers
31k
views
React Native with Unity
Does anyone have any experience combining React Native and Unity? I'm looking to start a Unity project that's very UI Heavy and I'm thinking about using React Native to take advantage of its UI ...
37
votes
9
answers
33k
views
Unity singleton manager classes
In Unity, whats a good way to create a singleton game manager that can be accessed everywhere as a global class with static variables that will spit the same constant values to every class that pulls ...
36
votes
11
answers
59k
views
How to get a random number from a range, excluding some values
In C#, how do I get a random number from a range of values - like 1..100, but that number should not be in some specific list of values, like 5, 7, 17, 23?