Last active
October 9, 2023 09:55
-
-
Save bibbis/2d905b508f90e2ab211fd67eda75e3b8 to your computer and use it in GitHub Desktop.
Unity Editor template where main class and editor class are both placed inside same file.
This file contains hidden or 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
using UnityEngine; | |
#if UNITY_EDITOR | |
using UnityEditor; | |
#endif | |
[System.Serializable] | |
public class ClassName | |
{ | |
public int Property1; | |
} | |
#if UNITY_EDITOR | |
[CustomEditor(typeof(ClassName))] | |
public class ClassNameEditor : Editor | |
{ | |
private SerializedProperty m_SerializedProperty; | |
private void OnEnable() | |
{ | |
m_SerializedProperty = serializedObject.FindProperty("m_SerializedProperty"); | |
} | |
public override void OnInspectorGUI() | |
{ | |
serializedObject.Update(); | |
serializedObject.ApplyModifiedProperties(); | |
} | |
} | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment