- Home /
Question by
maecky · Dec 30, 2011 at 12:09 PM ·
C# Show public members from a second class in Inspector
Hi, I have been searching the forum but wasn't able to find a solution, so hopefully you can help me ;).
I have two classes in c#:
public class CharacterController2D : MonoBehaviour {
public float test;
public MySecondClass[] mySecondClass = new MySecondClass[2];
}
public class MySecondClass {
public int testVar1;
public int testVar2;
}
If I drag this script over my player (or some other object in the game) I would like to manipulate the testVar1, testVar2 variables from the Inspector. But these variables don't show up. Does someone know what I'm doing wrong? Thanks in advance, Regards, Maecky
Comment
Best Answer
Answer by Statement · Dec 30, 2011 at 12:22 PM
Add System.Serializable attribute to your class.
[System.Serializable]
public class MySecondClass {
public int testVar1;
public int testVar2;
}
Your answer

Follow this Question
Related Questions
IEnumerator problems in C# 2 Answers
Is Input.GetAxis meant to return to 0 on key up? 1 Answer
Question regarding this line of code 1 Answer
how to convert int to string in C#? 2 Answers
Delay Problem, coule be 'OnMouseEnter'? 0 Answers