public override bool ShowState(Element element, ElementStateData sc, int index) { Color32 v = UnityEditor.EditorGUILayout.ColorField("顶颜色", sc.topColor); Color32 v2 = UnityEditor.EditorGUILayout.ColorField("底颜色", sc.bottomColor); if (ElementAgent.Color32Equal(ref v, ref sc.topColor) && ElementAgent.Color32Equal(ref v2, ref sc.bottomColor)) { return(false); } RegisterUndo <Color32>((ref Color32 vv) => { vv = v; }, ref sc.topColor); RegisterUndo <Color32>((ref Color32 vv) => { vv = v2; }, ref sc.bottomColor); return(true); }
public static bool DrawStateInfo(Element element, int stateid, bool isShowRecord, bool iscanset) { var target = (instance == null ? null : instance.Get()); EditorGUILayout.BeginHorizontal(); element.Agent.ShowElementState(element, stateid, iscanset); GUILayout.Space(-5); var preWidth = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = 40; var esd = element.stateData[stateid]; if (element.Agent.ShowState(element, esd, stateid)) { if (target == null || target.currentState == stateid) { element.Agent.Set(element, stateid); } } if (element.Agent.isSmooth) { GUI.changed = false; bool issmooth = GUILayout.Toggle(esd.isSmooth, "渐变", GUILayout.ExpandWidth(false)); float smoothTime = esd.smoothTime; if (issmooth) { smoothTime = EditorGUILayout.FloatField("时长", smoothTime); } if (GUI.changed) { ElementAgent.RegisterUndo(() => { esd.isSmooth = issmooth; esd.smoothTime = smoothTime; }); } } if (isShowRecord) { if (GUILayout.Button("记录")) { ElementAgent.RegisterUndo(() => { element.Agent.Init(element, element.stateData[stateid]); }); } } if (iscanset) { if (GUILayout.Button("移除")) { return(true); } } EditorGUIUtility.labelWidth = preWidth; EditorGUILayout.EndHorizontal(); return(false); }