TimeDilationDrawer.cs 717 B

1234567891011121314151617181920
  1. using UnityEditor;
  2. using UnityEngine;
  3. [CustomPropertyDrawer(typeof(TimeDilationBehaviour))]
  4. public class TimeDilationDrawer : PropertyDrawer
  5. {
  6. public override float GetPropertyHeight (SerializedProperty property, GUIContent label)
  7. {
  8. int fieldCount = 1;
  9. return fieldCount * EditorGUIUtility.singleLineHeight;
  10. }
  11. public override void OnGUI (Rect position, SerializedProperty property, GUIContent label)
  12. {
  13. SerializedProperty timeScaleProp = property.FindPropertyRelative("timeScale");
  14. Rect singleFieldRect = new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight);
  15. EditorGUI.PropertyField(singleFieldRect, timeScaleProp);
  16. }
  17. }