Hi Fabio,
Of course, I will be happy to.
These lines;
#if UNITY_EDITOR
// ....
#endif
are basically saying, “if the platform I am running on is the Unity editor, include these following lines”.
So, in your case, you were only using the three using
directives in between if the platform was Unity. When you did your build, they would have been ignored. As such, anything that relied upon those libraries/classes would have failed to be recognised by the compiler/loaded.
The next issue was that you have specified the UnityEditor.SceneManagement
directive, again, this will work within Unity, but if you are trying to run the game on another platform you still need the ability to load your scenes.
Note, all of these things were not in the course, as such I would, at least for now, follow the course more closely and you will avoid these issues. Then, gradually, expand on the functionality of each game by trying different things at that point.
On a related note, you would be doing yourself a big favour if you stick to naming conventions also, for example, class names and methods typically use PascalCase in C#, and variables camelCase.
So the methods you have, startgame
, optionsLoad
and doExitGame
would be better written as;
StartGame
, OptionsLoad
and DoExitGame
Then, consider naming them specifically for what they do, for example LoadOptions
and ExitGame
.
This will not only make your code easier to follow for yourself, but if you should happen to work with others, or just share your code online when asking for some help, it makes it a lot easier for everyone else also
Hope this helps