- Home /
Is it possible to write a custom inspector for a script that does not inherit from MonoBehaviour?
I have a class that does not inherit from MonoBehaviour, but that has the [System.Serializable] attribute on it. This class is instantiated on a script that does inherit from MonoBehaviour, like this:
[System.Serializable]
public class Class1
{
// Some code
}
public class Class2 : MonoBehaviour
{
[SerializeField] private Class1 class1;
}
I'm organizing things like this because I like how using the Serializable attribute allows me to create a dropdown menu of sorts on another class, and this is especially useful when I'm using it to edit a lot of data/parameters.
However, I'd like to know if it's possible to create a custom editor for a class like Class1 in the example above. So far it seems that only scripts that inherit from MonoBehaviour (either directly, or via a parent class) can have a custom editor, but I don't know too much about the system. Maybe it's possible for me to edit the way the Serializable class appears by creating a custom editor for Class2.
Your answer
Follow this Question
Related Questions
Assigning Serializable child class, not visible in Editor 1 Answer
Custom Display for system.object Editor 1 Answer
[Custom Editor] MonoBehaviour vs Scriptable Object 0 Answers
Custom class does not get serialized 2 Answers
How to do a custom editor for a ScriptableObject that is a property of a MonoBehaviour 2 Answers