GlobalPropInspector.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using UnityEngine;
  2. using UnityEditor;
  3. namespace DunGen.Editor
  4. {
  5. [CustomEditor(typeof(GlobalProp))]
  6. [CanEditMultipleObjects]
  7. public class GlobalPropInspector : UnityEditor.Editor
  8. {
  9. #region Labels
  10. private static class Label
  11. {
  12. public static readonly GUIContent PropGroupID = new GUIContent("Group ID", "The ID used by the dungeon flow to spawn instances of this prop");
  13. public static readonly GUIContent MainPathWeight = new GUIContent("Main Path", "Modifies the likelyhood that this object will be spawned while on the main path. Use 0 to disallow");
  14. public static readonly GUIContent BranchPathWeight = new GUIContent("Branch Path", "Modifies the likelyhood that this object will be spawned while on any of the branch paths. Use 0 to disallow");
  15. public static readonly GUIContent DepthWeightScale = new GUIContent("Depth Scale", "Modified the likelyhood that this obhect will be spawned based on how deep into the dungeon it is");
  16. public static readonly GUIContent WeightsHeader = new GUIContent("Weights");
  17. }
  18. #endregion
  19. private SerializedProperty propGroupID;
  20. private SerializedProperty mainPathWeight;
  21. private SerializedProperty branchPathWeight;
  22. private SerializedProperty depthWeightScale;
  23. private void OnEnable()
  24. {
  25. propGroupID = serializedObject.FindProperty("PropGroupID");
  26. mainPathWeight = serializedObject.FindProperty("MainPathWeight");
  27. branchPathWeight = serializedObject.FindProperty("BranchPathWeight");
  28. depthWeightScale = serializedObject.FindProperty("DepthWeightScale");
  29. }
  30. public override void OnInspectorGUI()
  31. {
  32. serializedObject.Update();
  33. EditorGUILayout.PropertyField(propGroupID, Label.PropGroupID);
  34. GUILayout.BeginVertical("box");
  35. EditorGUILayout.LabelField(Label.WeightsHeader, EditorStyles.boldLabel);
  36. EditorGUILayout.PropertyField(mainPathWeight, Label.MainPathWeight);
  37. EditorGUILayout.PropertyField(branchPathWeight, Label.BranchPathWeight);
  38. EditorGUILayout.CurveField(depthWeightScale, Color.white, new Rect(0, 0, 1, 1), Label.DepthWeightScale);
  39. GUILayout.EndVertical();
  40. serializedObject.ApplyModifiedProperties();
  41. }
  42. }
  43. }