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<int, GameObject>(). You won't have to box/unbox the int and no casting.

1 Answer

1

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.