im using C# monodevelop-unity and I was watching a video on how to make a basic game and
some of his code don't work on my game but he is using VisualStudio would that change anything every other code that he did worked on monodevelop but not this one
Code:
using UnityEngine;
using UnityEngine.SceneManagement;
public class GameManager : MonoBehaviour {
bool gameHasEnded = false;
public void EndGame ()
{
if (gameHasEnded == false)
{
gameHasEnded = true;
Debug.Log ("Game Over");
// Restarting game
}
}
void Restart ();
{
SceneManager.LoadScene.(SceneManager.GetActiveScene().name);
}
}
First off, please take a look at this thread and then put your code in code tags: Using code tags properly - Unity Engine - Unity Discussions
Secondly, it shouldn’t make a difference no. One thing I’ll point out is this part:
SceneManager.Load(SceneManager.().name);
Not sure what you were attempting to type here, but “SceneManager.().name” is not correct. Verify what the tutorial video said you should type in there. Anyways, fixing that might fix whatever your issue is… but if not, you need to actually tell us what your issue is, including any errors you may be receiving.
oops i did it wrong i deleted some stuff to see if it worked here is the accually part that i was trying to write
ScenceManager.LoadScene(SceneManager.GetActiveScene().name);
here is the link to the video:
the time should be somewhere in between 8:40 and 8:50
I don’t really understand code yet i just started yesterday so I don’t get what he’s trying to do in the link that u sent me
and when im typing code you know how it shows you what your options are for some code like if i put Debug. and it would show up a suggestion for Debug.Log it dosn't show the suggestions for ScenceManager.LoadScene(SceneManager.GetActiveScene().name); so im not sure if its monodevelop and I was told that monodevelop was for mac is that true because im on windows[/COLOR]
The link I sent was so that you can paste code HERE and have it look like how I pasted coded in my paste (which is formatted, highlighted, and a lot easier for everyone else to read).
I’m not clear from your 2nd post though if you’re still having a problem now that you found the error, but if you are, please tell us what’s happening now (errors?? if so, what?)
I use MonoDevelop on Windows. I think a lot of people prefer something else, but I really like it for Unity, myself.
Typing “Scenemanager.” should bring up some suggestions in MonoDevelop too, I think… if not, I wonder if you’re using an older version of Unity? The SceneManagement class is new as of 5.3
i made a video on it and ill show you
never mind it didnt work
this is the error 1
Assets/Scripts/GameManager.cs(20,2): error CS9010: Primary constructor body is not allowed
and error 2
Assets/Scripts/GameManager.cs(21,25): error CS1001: Unexpected symbol `(', expecting identifier
That post I mentioned earlier on using code tags , you really need to do this, as when you don’t, it makes it a lot harder on anyone to understand code you’ve posted. The link tells you exactly how and why to use code tags… it’s pretty simple. Please read that link first, and, using “code tags”, paste your code you have now after having fixed the initial typo I’ve pointed out.
Assets/Scripts/GameManager.cs(21,25): error CS1001: Unexpected symbol `(', expecting identifier
Assets/Scripts/GameManager.cs(20,2): error CS9010: Primary constructor body is not allowed
haha, no, not your error in code tags… your code… i.e. the stuff in post 1, but with your recent changes. At least you used code tags this time though ![]()
oh ok lol
im using unity 5.6.1f1
Are you going to paste your latest code here (Again, use the code tags for that… code tags are for making code more easily readable here).
and i changed the code in post 1 and corrected it and moved it down here
im using C# monodevelop-unity and I was watching a video on how to make a basic game and
some of his code don't work on my game but he is using VisualStudio would that change anything every other code that he did worked on monodevelop but not this one
Code:
using UnityEngine;
using UnityEngine.SceneManagement;
public class GameManager : MonoBehaviour {
bool gameHasEnded = false;
public void EndGame ()
{
if (gameHasEnded == false)
{
gameHasEnded = true;
Debug.Log ("Game Over");
// Restarting game
}
}
void Restart ();
{
SceneManager.LoadScene.(SceneManager.GetActiveScene().name);
}
}
Oh man… you’re killing me here. lol So code tags are for code, and only code… you put your code in between the code tags (thus why they’re called code tags), everything else outside of the code tags. But it’s all good, as I can see your error is here:
SceneManager.LoadScene.(SceneManager.GetActiveScene().name);
It should be:
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
You need to have a lot more attention to detail when coding… type exactly what the video says. Anyways, correct the line above with my code, and I think you should be good.
oh ty ill see if that worked