I’m trying to make a list of hashtables but I am getting errors
var animations=new List.<Hashtable>();
when I try to use the hashes list I get errors like
hashes[“rotations”].Count --count is not a member of object etc…
Is this because it doesn’t know what rotations is because it is not declared outside of the
Is there a better way to go about doing this. The basic idea
is to have an animation that hold many different properties?
Should I create a class instead?
Can I make a list of classes?
can I do animations=List.() if animation is a class?
That error is likely because the hash table stores its entries in a String => Object (string to object) association, so you get getting an object back from the hashes[“rotations”] and then trying to access a list variable.
Try something like so:
(hashes["rotations"] as List).Count
You basically just have to remember to cast things as you go to ensure the compiler knows what you are using at any given point.
Hope that makes sense.
Well, Hashtable will store objects of type Object, if you don’t declare anything else. So it will accept both strings and lists, as you show, but it will not be able to find the type of anything stored until runtime.
You could declare a specific type of Hashtable if you need to, unless my assumptions about unityscript are wrong.
var animations = new List.<Hashtable<string, List<Vector3>>>();
I would seriously consider if this stuff is really necessary.