- Home /
Question by
Steven-Walker · Mar 25, 2011 at 10:20 PM ·
variablesclassesproperty
Abstracting class vars, accessing vars by variable
Dear Unity JS Gurus....
Is there a way to get/set a class member variable by name, rather than hard-coding it? In an ideal world, here is pseudo code for what I'd like to do.
function SetProperties(properties : Hashtable) {
for(var property : DictionaryEntry in properties) {
var varName : String = property.Key;
this.varName = property.Value;
}
}
I only care about using this in edit mode if it makes a difference to anyone. I have many editor scripts and there's a lot of repetition in reading/writing variable sets (ie. saving and loading settings). If I could abstract it with a base class, I'd have more time to focus on more fun stuff.
Thanks, Steven
Comment