[System.Serializable]
public class OurClass
{
int a = 0;
string b = "blabla"
}
in the test script we describe a variable of our class
public class Test : MonoBehaviour
{
public OurClass ourClass = new OurClass();
}
As a default we see in inspector a foldout with int and string variables
But what if I want my variable look different? Is it any possible? For example AnimationCurve has its own presence in inspector…
So, any ideas?
You can implement a custom inspector for your type.
Drop this script in to your Assets/Editor folder and you’re good to go:
[CustomEditor(typeof(OurClass))]
public class OurClassInspector : Editor
{
public override void OnInspectorGUI()
{
// Set up your GUI here
target.a = EditorGUILayout.Slider(target.a, 0, 100);
}
}
But OurClass is not derived from MonoBehaviour, so it cannot be used as component.
I’d like to use it as a type for a variable and see custom inspector only for this variable - when it’s declared in another script.
Might be, but you will have to cope with it if you want it to look different or you will just see what they are and what comes out due to the serialization.
Don’t use an int, float or string if you want it to be an animation curve
Also its a 1 time work per class basically so not a problem.