so I noticed that if you click on project settings, you can select options in unity. you can view a preset variable like GRAVITY for instance. You can edit this during runtime AND set its value before runtime.;
There is also a way to extend the editor. I have seen how it is possible to create new vindows with input field that hold integers and float and anything. I am not able however to create arrays and this is a problem.
what I basically need is to create a built in game menu that extends the editor. it has an array that can be resized. It is NOT a monobehavior and hold essential variables for the game, example are:
lists of inventory items, their names and cost and wtv
lists of playable or non playable characters
lists of other game elements such as score or wtv
unity is great as it offers scripts to place in object, but when it comes to extending the unity editor and creating built-in variable I am having some trouble.
the main trouble is I need these built in values to be saved before gameplay (like gravity is in the project settings menu) and also editable in runtime.
You could use a “dummy” GameObject in the scene purely to hold the data for the editor script. You could remove it from the final build if you are concerned about its effect on performance.
Well, if you want your lists to be saved, you can’t do it without creating an asset or object in the scene.
Having a dummy GameObject for the purpose of holding data isn’t really bad. I usually have a gameobject with a singleton monobehaviour script in my scene for the purpose of data holding. If you want a fancy editor for your data holder, you can create a menu item like “Game Settings” in unity menu, then you can open an editor window in which you can list all the settings as you like.
The data in any of the menus under Project Settings is not saved in the /Assets folder or a GameObject in the scene. Can this be done with the current Editor extensions?
You can just create a prefab in a Resources/ folder then access the values directly without instantiating it (can use Resources.Load to access resources). You will have the full structure of mono behaviours and unity’s default inspector (if you use System.Serializable on classes you can create a complex data structure if necessary, by composition) so this is generally a good way to store data.