备份CatanBuilding瘦身独立工程
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
|
||||
#if UNITY_EDITOR
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.Linq;
|
||||
|
||||
public class AngleSelectorAttribute : PropertyAttribute { }
|
||||
|
||||
|
||||
[CustomPropertyDrawer(typeof(AngleSelectorAttribute))]
|
||||
public class CubeInspectorAngle : PropertyDrawer
|
||||
{
|
||||
private readonly int[] angles = { 0, 90, 180, 270 };
|
||||
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
if (property.propertyType == SerializedPropertyType.Integer)
|
||||
{
|
||||
int currentAngle = property.intValue;
|
||||
int selectedIndex = Mathf.Max(0, System.Array.IndexOf(angles, currentAngle));
|
||||
selectedIndex = EditorGUI.Popup(position, label.text, selectedIndex, angles.Select(a => a.ToString()).ToArray());
|
||||
property.intValue = angles[selectedIndex];
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUI.LabelField(position, label.text, "Use [AngleSelector] with int.");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user