- Home /
Question by
ArkEidolon · Nov 13, 2012 at 04:23 AM ·
inspectorvariablesclass
Showing public class variables in another class in the Inspector.
I have something like this:
public class Student
{
int age;
string name;
float height;
float grades[];
}
public class StudentCollection
{
public Student stud1;
public Student stud2;
public Student stud3;
}
Now I want the students to appear in the Inspector like this:
> Stud1
> Stud2
> Stud3
And when I click the arrow of Stud1, it should look like this:
asd
v Stud1
Age ________
Name _______
Height _____
v Grades
Size 2
Element 0 _______________
Element 1 _______________
> Stud2
> Stud3
Is this possible? T__T Thanks in advance.
Comment
Answer by svenskefan · Nov 13, 2012 at 08:34 AM
Hi! You could use Lists for this.
you need something like:
using System.Collections.Generic
class blabla:Monobehaviour
public List<student> studentlist;
IMPORTANT, you also need to add a directive before your Student class, like so
[Serializable]
class Student
this way the "studentlist" will work like any other List in the Unity inspector, set size and set properties on elements etc.