1
0
Fork 0
LaboratoryProtection/Assets/OtherPackage/DefaultPlayables/TextSwitcher/Editor/TextSwitcherDrawer.cs

31 lines
1.1 KiB
C#
Raw Permalink Normal View History

2023-09-12 15:55:51 +08:00
using UnityEditor;
using UnityEngine;
using UnityEngine.Playables;
using UnityEngine.UI;
[CustomPropertyDrawer(typeof(TextSwitcherBehaviour))]
public class TextSwitcherDrawer : PropertyDrawer
{
public override float GetPropertyHeight (SerializedProperty property, GUIContent label)
{
int fieldCount = 3;
return fieldCount * EditorGUIUtility.singleLineHeight;
}
public override void OnGUI (Rect position, SerializedProperty property, GUIContent label)
{
SerializedProperty colorProp = property.FindPropertyRelative("color");
SerializedProperty fontSizeProp = property.FindPropertyRelative("fontSize");
SerializedProperty textProp = property.FindPropertyRelative("text");
Rect singleFieldRect = new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight);
EditorGUI.PropertyField(singleFieldRect, colorProp);
singleFieldRect.y += EditorGUIUtility.singleLineHeight;
EditorGUI.PropertyField(singleFieldRect, fontSizeProp);
singleFieldRect.y += EditorGUIUtility.singleLineHeight;
EditorGUI.PropertyField(singleFieldRect, textProp);
}
}