- Home /
how to see class driven out of class in inspector?
using UnityEngine;
using System.Collections;
public class Script : MonoBehaviour {
public int Class1 = 0;
[System.Serializable]
public class ClassA : Script{
public int ClassA1 = 0;
}
}
[System.Serializable]
public class ClassB : Script{
public int ClassB1 = 0;
}
all I see is only:
Class1 = 0;
how to see ClassA & B? in inspector?
using debug or normal view doesn't help
You seem to be mixing a couple concepts here. For one, you can use inheritance in code and it shows correctly in the inspector - if "ClassB" derives from "Script", then putting "ClassB" component on a GameObject will show public variables from both classes.
For two, having an internal class inherit from the outer class seems unusual to me - I've never seen a reason to do that, but maybe it's fine. As Happy$$anonymous$$oo demonstrates below, you can create "data classes" with System.Serializable that show up in the inspector, conveniently enough, as foldable sections.
sadly I haven't managed to see data in inspector
but I did saw some people managed that and I was wandering how to do it, ...
but I just can't manage to do it.
for example JS character motor has is, ... but rearing JS for me is like reading chinese translated in your language. more than 50% is wrongly translated and If you'd translate answer back to their lang. they say what the hell are you talking about, ...
Answer by HappyMoo · Jan 07, 2014 at 07:14 AM
You can't see classes in the inspector... only fields of that type.
And you don't need to derive from MonoBehaviour just to hold some data - in fact, that's a bad idea.
using UnityEngine;
using System.Collections;
public class Script : MonoBehaviour {
public int Class1 = 0;
public ClassA myA;
}
[System.Serializable]
public class ClassA{
public int ClassA1 = 0;
}