Loading a level in unity 5.5.0f3 [closed] - c#

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 5 years ago.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Improve this question
I am using unity 5.5.03f and I want to reload a screen once the character hits an obstacle, I do have the box colliders attached to both. But the code that I have is not working.
This is the code that I have for restarting the screen:
using UnityEngine.SceneManagement;
.
.
.
void onCollisionEnter2D(Collision2D collision){
// get the current scene name
string sceneName = SceneManager.GetActiveScene().name;
// load the same scene
SceneManager.LoadScene(sceneName, LoadSceneMode.Single);
}
I am using C# as my programming language for unity.
Any help and advice will be highly appreciated.

The code is fine.
But the function name would be OnCollisionEnter2D, not onCollisionEnter2D

Related

Unity3D activeSelf function always returns true [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
In my game, I have a script for switching weapons. The script relies on activating and deactivating gameObjects that you have picked up. As of now, the gameObjects get set inactive in unity, but the function activeSelf returns true no matter the actual state. A part of my script is attached. The If-statement works well and I can monitor the state in Debug.Log.
This should not be happening, and I have no idea what's the cause.
You control activity of weapon.gameObject, but then you check gameObject
gameObject.activeSelf returns same result every time because you don’t change it actually. You change weapon.gameObject.selfActive

Why Debug.Writeline is printing my message in reverse [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 7 years ago.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Improve this question
I write something like this:
Debug.WriteLine("RefKey value was {0}", refKey);
And then in output window I see:
200002V0dH: refInterfaceKey was {0}
Why is it kind of printing it right to left?
The format of this function is WriteLine(string message,string category). This means that it will show your category and then, your message. For instance, category could be TRACE or DEBUG.
I think that what you are looking for is string.Format. You should have
Debug.WriteLine(String.Format("RefKey value was {0}", refKey))

Converting selected combobox item to useable string variable [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 7 years ago.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Improve this question
I'd like to know how I can take an item selected in my combobox, and convert it to a string variable, which I then use to complete my MySQL query. I'm very much a beginner at C# so any help would be appreciated.
I've tried the following code which I found here on stackoverflow, but it doesn't do the trick. I tried to fill the label1 so I could see if it's working, but I actually need to put it into an mysql query:
string selected0
= this.clubComboBox0.GetItemText(this.clubComboBox0.SelectedItem);
label1.Text = selected0;

How to decrease a number with a percentage C# [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I'm working on a game project in Unity. My issue is that I want to take a number and decrease it by a specific percentage. Can I could be pointed to a good resource or provided with a good answer.
What's unity?
float results = OriginalValue - (OriginalValue * Percent / 100);

How to get the default gateway of a router where I connected using C#? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I can't figure out how to get it. I googled a lot since yesterday and I do not found any answer.
Any Ideas?
Loop through NetworkInterface.GetAllNetworkInterfaces() until you find the one you want, then look at GetIPProperties().GatewayAddresses.

Categories

Resources