1234567891011121314151617181920212223242526272829303132333435363738394041 |
- using UnityEngine;
- #if UNITY_EDITOR
- using UnityEditor;
- #endif
- public class SelectableLabelAttribute : PropertyAttribute
- {
- public string text;
- public SelectableLabelAttribute(string text)
- {
- this.text = text;
- }
- }
- #if UNITY_EDITOR
- [CustomPropertyDrawer(typeof(SelectableLabelAttribute))]
- public class SelectableLabelDrawer : PropertyDrawer
- {
- public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
- {
- EditorGUI.SelectableLabel(position, selectableLabelAttribute.text);
- }
- private SelectableLabelAttribute selectableLabelAttribute
- {
- get
- {
- return (SelectableLabelAttribute)attribute;
- }
- }
- public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
- {
- return selectableLabelAttribute.text.Split('\n').Length * base.GetPropertyHeight(property, label);
- }
- }
- #endif
|