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.

61 lines
2.0 KiB

5 years ago
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEditorInternal;
  5. using UnityEditor;
  6. [CustomEditor(typeof(FogVolumeData))]
  7. public class FogVolumeDataEditor : Editor
  8. {
  9. FogVolumeData _target;
  10. void OnEnable()
  11. {
  12. _target = (FogVolumeData)target;
  13. }
  14. private static bool SHOW_DEBUG_DATA
  15. {
  16. get { return EditorPrefs.GetBool("SHOW_DEBUG_DATATab", false); }
  17. set { EditorPrefs.SetBool("SHOW_DEBUG_DATATab", value); }
  18. }
  19. public override void OnInspectorGUI()
  20. {
  21. serializedObject.Update();
  22. EditorGUI.BeginChangeCheck();
  23. GUILayout.Space(10);
  24. _target.GameCamera = (Camera)EditorGUILayout.ObjectField("Game Camera", _target.GameCamera, typeof(Camera), true);
  25. _target.ForceNoRenderer = EditorGUILayout.Toggle("Disable Camera script", _target.ForceNoRenderer);
  26. GUILayout.Space(10);
  27. if (GUILayout.Button("DEBUG DATA", EditorStyles.toolbarButton))
  28. SHOW_DEBUG_DATA = !SHOW_DEBUG_DATA;
  29. if (SHOW_DEBUG_DATA)
  30. {
  31. var FoundCameras = serializedObject.FindProperty("FoundCameras");
  32. GUILayout.BeginVertical("box");
  33. EditorGUI.indentLevel++;
  34. EditorGUILayout.PropertyField(FoundCameras, new GUIContent("Available Cameras:"), true);
  35. EditorGUI.indentLevel--;
  36. GUILayout.EndVertical();
  37. var SceneFogVolumes = serializedObject.FindProperty("SceneFogVolumes");
  38. GUILayout.BeginVertical("box");
  39. EditorGUI.indentLevel++;
  40. EditorGUILayout.PropertyField(SceneFogVolumes, new GUIContent("Available Fog Volumes:"), true);
  41. EditorGUI.indentLevel--;
  42. GUILayout.EndVertical();
  43. }
  44. EditorGUI.EndChangeCheck();
  45. if (GUI.changed)
  46. {
  47. Undo.RecordObject(target, "Fog volume Data modified");
  48. EditorUtility.SetDirty(target);
  49. }
  50. serializedObject.ApplyModifiedProperties();
  51. }
  52. }