- Home /
Editting a custom javascript class in the inspector
Hey guys! Is there any way to edit a custom class like
var animals : Animals[];
class Animals {
var dog : Transform;
var neighbour : Transform;
var otherAnimal : Animals;
}
because everything except the otherAnimal var works fine. I can edit the array trough the inspector, edit all of the elements separately but the otherAnimal variable is not visible.
David
Answer by Eric5h5 · Mar 10, 2012 at 06:39 PM
That's because it's infinitely recursive. Are you sure you want a class where one of the members refers to the class?
Well...I can do it without it anyways, but are you saying that there is no way to do that?
I'm saying I can't imagine why you would want to do that. ;) In your class Animals, otherAnimals is of type Animals, which contains dog + neighbour + otherAnimals, which contains dog + neighbour + otherAnimals, which contains dog + neighbour + otherAnimals, and so on forever. That can't be displayed in the inspector, because it's infinitely nested and so would require an infinite amount of memory.
Your answer
Follow this Question
Related Questions
Accessing variables and arrays from inside classes? 1 Answer
Access to a variable inside a C# class 2 Answers
Different way to access class variables? 1 Answer
How to get the number of variables in a class, and then call the variable by its number. 1 Answer
Reading reference variable alters said reference variable 1 Answer