Created
December 10, 2018 12:41
-
-
Save thelastpointer/7546c0a94390f489d398c912f7645895 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Sample custom editor for a class in the same file. | |
I've yet to encounter errors with compilation order. | |
*/ | |
using UnityEngine; | |
#if UNITY_EDITOR | |
using UnityEditor; | |
#endif | |
namespace Project | |
{ | |
public class ClassWithCustomEditor : MonoBehaviour | |
{ | |
[SerializeField] | |
private Vector2 propertyInEditor; | |
//... | |
} | |
} | |
#if UNITY_EDITOR | |
namespace Project.Editors | |
{ | |
[CustomEditor(typeof(ClassWithCustomEditor))] | |
public class ClassWithCustomEditorEditor : Editor | |
{ | |
public override void OnInspectorGUI() | |
{ | |
serializedObject.Update(); | |
EditorGUILayout.LabelField("Some customization here"); | |
EditorGUILayout.PropertyField(serializedObject.FindProperty("propertyInEditor")); | |
serializedObject.ApplyModifiedProperties(); | |
} | |
} | |
} | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment