Skip to content

Instantly share code, notes, and snippets.

@bibbis
Last active October 9, 2023 09:55
Show Gist options
  • Save bibbis/2d905b508f90e2ab211fd67eda75e3b8 to your computer and use it in GitHub Desktop.
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.
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