You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.7 KiB

5 years ago
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEditor;
  5. [CustomEditor(typeof(FogVolumePrimitive))]
  6. public class FogVolumePrimitiveEditor : Editor
  7. {
  8. public override void OnInspectorGUI()
  9. {
  10. GUILayout.Space(10.0f);
  11. serializedObject.Update();
  12. GUILayout.BeginVertical("box");
  13. var enabled = serializedObject.FindProperty("IsSubtractive");
  14. int selectedActionType = enabled.boolValue ? 0 : 1;
  15. selectedActionType =
  16. EditorGUILayout.Popup("Action Type: ",
  17. selectedActionType,
  18. m_actionTypes,
  19. EditorStyles.toolbarButton);
  20. if (selectedActionType == 0) { enabled.boolValue = true; }
  21. else { enabled.boolValue = false; }
  22. var persistent = serializedObject.FindProperty("IsPersistent");
  23. int selectedPersistenceType = persistent.boolValue ? 0 : 1;
  24. selectedPersistenceType =
  25. EditorGUILayout.Popup("Persistence Type:",
  26. selectedPersistenceType,
  27. m_persistenceType,
  28. EditorStyles.toolbarButton);
  29. if (selectedPersistenceType == 0) { persistent.boolValue = true; }
  30. else { persistent.boolValue = false; }
  31. GUILayout.Space(2.0f);
  32. GUILayout.EndVertical();
  33. serializedObject.ApplyModifiedProperties();
  34. }
  35. private readonly string[] m_actionTypes = new[]
  36. {
  37. "Subtractive",
  38. "Additive"
  39. };
  40. private readonly string[] m_persistenceType = new[]
  41. {
  42. "Persistent",
  43. "Cullable"
  44. };
  45. }