- Home /
Editor-populated Hashtables are reset on a sneeze.
Hey guys.
EDITED for clarity.
- I have an editor script that serves as a manager.
- From there, the user set-up various stuff he needs to use : Vector3, Strings, Ints.
- I don't know how many or what types, it could be custom class he made.
- The manager then adds a "Datanode.js" script to a GameObject on the scene.
- Datanode.js contains a Hashtable, which is the easiest way to add such varied information which the user can recall easily with only a name.
- There can be lots of these Datanode.
The user should be able to recall those info at runtime or editor-mode. It works in Editor-mode but as soon as I hit play, or Unity recompiles, all datas are lost. The only way I seem to be able to retain data is by using single predefined vars (int,String,boolean,float) and possibly built-in arrays. Which is definitly not handy for the user to remember.
Any hints/tips/ideas on how to achieve my needs?
On a side note: you should use a Dictionary(). You won't have to box/unbox the int and no casting.
Answer by by0log1c · Apr 11, 2011 at 02:04 AM
I've tried using List.<> and faced the same problem.
I solved by using a built-in array of a custom class "Data". Everything's good except I need to set the size, and thus a maximum data nodes beforehand. I figure I can work-around by making a function that would create a new built-in and restore the previous data.
In any case, my datas are now kept safely.
Your answer
Follow this Question
Related Questions
Unity 4.5 Mac OSX Won't Compile Scripts 4 Answers
Unity shortcut does not work after compiling code changes 1 Answer
Do scripts in a folder called "Editor" get left out of a build? 1 Answer
How do you clear a variable in the inspector? 4 Answers
Unity freezes temporarily when recompiling/refreshing scripts 2 Answers