- Home /
Question by
Kwillson805 · Apr 18, 2018 at 05:34 AM ·
editorcustom editorattribute
Field Attribute to auto insert in custom inspector
So I write a lot of custom inspectors and I was wondering if there was a way to add an attribute to a field that automatically puts it in the custom inspector. And where it grabs the tooltip attribute act as the GUIContent. So something like:
public class ClassA : MonoBehaviour
{
/// <summary>
/// Some wiki content blah blah blah
/// </summary>
[AutoCustomInspector]
[Tooltip("Some wiki content blah blah blah")]
private GameObject SomeGameObject;
// code
}
[CustomEditor(typeof(ClassA ), true)]
[CanEditMultipleObjects]
public class ClassAEditor : Editor
{
public override void OnInspectorGUI()
{
var myScript = target as ClassA;
// I DONT WANT TO WRITE THIS
myScript.SomeGameObject = (GameObject)EditorGUILayout.ObjectField(new GUIContent("Some Game Object", "Some wiki content blah blah blah"), myScript.SomeGameObject, typeof(GameObject), true);
}
}
I've look into Attributes but haven't really found anything useful, so any help would be appreciated
Comment