LightControlDrawer.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233
  1. using UnityEditor;
  2. using UnityEngine;
  3. using UnityEngine.Playables;
  4. [CustomPropertyDrawer(typeof(LightControlBehaviour))]
  5. public class LightControlDrawer : PropertyDrawer
  6. {
  7. public override float GetPropertyHeight (SerializedProperty property, GUIContent label)
  8. {
  9. int fieldCount = 4;
  10. return fieldCount * EditorGUIUtility.singleLineHeight;
  11. }
  12. public override void OnGUI (Rect position, SerializedProperty property, GUIContent label)
  13. {
  14. SerializedProperty colorProp = property.FindPropertyRelative("color");
  15. SerializedProperty intensityProp = property.FindPropertyRelative("intensity");
  16. SerializedProperty bounceIntensityProp = property.FindPropertyRelative("bounceIntensity");
  17. SerializedProperty rangeProp = property.FindPropertyRelative("range");
  18. Rect singleFieldRect = new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight);
  19. EditorGUI.PropertyField(singleFieldRect, colorProp);
  20. singleFieldRect.y += EditorGUIUtility.singleLineHeight;
  21. EditorGUI.PropertyField(singleFieldRect, intensityProp);
  22. singleFieldRect.y += EditorGUIUtility.singleLineHeight;
  23. EditorGUI.PropertyField(singleFieldRect, bounceIntensityProp);
  24. singleFieldRect.y += EditorGUIUtility.singleLineHeight;
  25. EditorGUI.PropertyField(singleFieldRect, rangeProp);
  26. }
  27. }