Super Knight : Enter the Dungeon
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.2 KiB

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