I just spent a week writing some editor code that allows me to place spawn points around my map (in the editor).
The editor script, SpawnEditorWindow, resides in the Editor folder.
The manager for that script, called SpawnPointManager (resides outside Editor folder), is connected to an empty game object in my scene.
Also connected to that empty game object is another script called SpawnManager, which communicates with my in-game pauseMenu to spawn all the characters in the map at runtime.
SpawnManager draws information from SpawnPointManager, which in turn figure out how many spawns there are from SpawnEditorWindow (basically, from the editor slider bars).
So, on to my problem... This works beautifully inside the editor. I hook everything up, open the spawn editor window, adjust how many spawns I want, position them, etc.
However... when I go to run this, the List those spawns isn't initalized... or maybe it's reintialized, I don't know. Anyway, the List count is zero, thus no spawns exist.
What are my options here? How can I get this information into runtime? It's a List.
If you put your own custom class into a list it have to be Serialized not to disappear. So if you have a custom SpawnPoint script you need to use the [System.Serializable] attribute:
answered Mar 16 '12 at 03:37 PM
You could have a game object with a script containing a List and have your editor script Find it and copy to it.
answered Mar 16 '12 at 07:16 AM