First of all, sorry about my english… Im c# .net programmer, but totaly new in make games. I was using Stencyl for a while, but want to migrate to Unity.
I want to know a basic thing. How can I make to create global attributes for my game, and set initial values for them? And how to bind this global attributes script in the begining of the game?
Example:
I need some attributes to rule the game, like highscore, level, dificult, etc.
You can put what you broadly call “initial attributes” into a number of different places in Unity3D, depending upon their intended scope and lifetime:
hard-coded into C# or JS code
editor prefab fields
editor scene object fields
listed in a text file (TextAsset) within the project
Something like a HighScore and/or difficulty setting would probably be best in a PlayerPrefs field. You can even give it an initial value if one has never been set before.
Each of the above places has advantages and disadvantages and may or may not be appropriate to the particular problem you are trying to solve. Experiment! Read the documentation, get a feel for how it all works.
The inspector creates a menu entry to create the GameObject singletons default being added to.
Next, any “manager” you inherit from the ‘Singleton’ class (instead of MonoBehaviour), then on the singleton manager object you’ll notice that their is a drop down that list all possible Singletons that are known. You can select any to add them to the gameobject.