DoorwaySocketInspector.cs 959 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using UnityEditor;
  2. using UnityEngine;
  3. namespace DunGen.Editor
  4. {
  5. [CustomEditor(typeof(DoorwaySocket))]
  6. public sealed class DoorwaySocketInspector : UnityEditor.Editor
  7. {
  8. #region Labels & SerializedProperties
  9. private static class Labels
  10. {
  11. public static readonly GUIContent Size = new GUIContent("Size", "The size of the doorway opening. Used for visualization and portal culling");
  12. }
  13. private class Properties
  14. {
  15. public SerializedProperty Size { get; private set; }
  16. public Properties(SerializedObject obj)
  17. {
  18. Size = obj.FindProperty("size");
  19. }
  20. }
  21. #endregion
  22. private Properties properties;
  23. private void OnEnable()
  24. {
  25. properties = new Properties(serializedObject);
  26. }
  27. public override void OnInspectorGUI()
  28. {
  29. serializedObject.Update();
  30. EditorGUILayout.PropertyField(properties.Size, Labels.Size);
  31. serializedObject.ApplyModifiedProperties();
  32. }
  33. }
  34. }