- Home /
Inspector Definitions for New Script Components Problem
Sup, cheers for reading;
Here's the issue; If you highlight a script in the project, all of its public (inspector declarable) elements appear in the inspector, above the script itself. I have assumed (incorrectly?) that if you then spawned that script, the definitions that you dragged into those places would work, as "defaults".
The problem is it does not work, which makes me think that its just a read-only type interface, and is only used to remind the developer about what is public inside it.
As far as I can see, there is no way to declare a new script while continuing to use those pre-defined (inspector defined) variables. Here is the relevant code;
PM = gameObject.AddComponent("Player_Manager") as Player_Manager;
HM = gameObject.AddComponent("HUD_Manager") as HUD_Manager;
MM = gameObject.AddComponent("Map_Manager") as Map_Manager;
IM = gameObject.AddComponent("Item_Manager") as Item_Manager;
AM = gameObject.AddComponent("AI_Manager") as AI_Manager;
WM = gameObject.AddComponent("World_Manager") as World_Manager;
Each of these scripts is a public static script, thus, to access any of them in game, I simply need to go Gameplay_Manager.PM.DoSomething(); I can do this in any other script, so I don't need to find any scripts anywhere else, I just need to get the static references, which is handy.
Alternatively, it would also be nice to know the best way to gather un-initialized game objects into the run-time for use. I've heard that Resources.Load() is bad (and you need a resources folder, which would mess with my organisation XD)
Cheers for the help.