Unity Odin (实现如图所示效果)(九)
代码
using System;
using Sirenix.OdinInspector.Editor;
using Sirenix.Utilities.Editor;
using UnityEngine;
public class DateTimeDraw : OdinValueDrawer<DateTime>
{
private string str;
private object key = new object();
protected override void DrawPropertyLayout(GUIContent label)
{
str = this.ValueEntry.SmartValue.ToString();
SirenixEditorGUI.BeginShakeableGroup(key);
str = SirenixEditorFields.TextField(label,str);
if (DateTime.TryParse(str, out var res))
this.ValueEntry.SmartValue = res;
else
{
SirenixEditorGUI.StartShakingGroup(key);
Debug.Log("1");
}
SirenixEditorGUI.EndShakeableGroup(key);
}
}