Files
JourneyToNowhere_Unity/Assets/Editor/ShowOnlyDrawer.cs
T
2024-01-27 08:49:55 +08:00

32 lines
1004 B
C#
Executable File

using UnityEditor;
using UnityEngine;
[CustomPropertyDrawer(typeof(ShowOnlyAttribute))]
public class ShowOnlyDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty prop, GUIContent label)
{
string valueStr;
switch (prop.propertyType)
{
case SerializedPropertyType.Integer:
valueStr = prop.intValue.ToString();
break;
case SerializedPropertyType.Boolean:
valueStr = prop.boolValue.ToString();
break;
case SerializedPropertyType.Float:
valueStr = prop.floatValue.ToString("0.00000");
break;
case SerializedPropertyType.String:
valueStr = prop.stringValue;
break;
default:
valueStr = "(not supported)";
break;
}
EditorGUI.LabelField(position, label.text, valueStr);
}
}