public override void Init(Element element, ElementStateData sd) { if (element.target != null) { sd.obj = element.GetTarget <Text>().font; } }
public override void Init(Element element, ElementStateData sd) { if (element.target != null) { sd.strValue = element.GetTarget <Text>().text; } }
public override bool ShowState(Element element, ElementStateData sc, int index) { Material old = sc.obj as Material; Material material = (Material)EditorGUILayout.ObjectField(old, typeof(Material), false); if (GUILayout.Button("灰")) { material = Resources.Load <Material>("UIGray"); } if (GUILayout.Button("空")) { material = null; } if (material != old) { RegisterUndo(() => { sc.obj = material; if (sc.obj == Graphic.defaultGraphicMaterial) { sc.obj = null; } }); return(true); } return(false); }
public override void Init(Element element, ElementStateData sd) { if (element.target != null) { sd.isEnable = element.GetTarget <GameObject>().activeSelf; } }
public override void Init(Element element, ElementStateData sd) { if (element.target != null) { sd.vector3 = element.GetTarget <Transform>().localPosition; } }
public override void Init(Element element, ElementStateData sd) { if (element.target != null) { sd.vector3.x = element.GetTarget <RectTransform>().rect.width; } }
public override void Init(Element element, ElementStateData sd) { if (element.target != null) { sd.vector3.x = element.GetTarget <CanvasGroup>().alpha; } }
public override void Init(Element element, ElementStateData sd) { if (element.target != null) { sd.color32 = element.GetTarget <MaskableGraphic>().color; } }
public override void Init(Element element, ElementStateData sd) { if (element.target != null) { sd.obj = element.GetTarget <Image>().sprite; } }
public override void Init(Element element, ElementStateData sd) { if (element.target != null) { Graphic graphic = element.GetTarget <Graphic>(); sd.obj = GetGraphicMaterial(graphic); } }
public override void Init(Element element, ElementStateData sd) { if (element.target != null) { sd.topColor = element.GetTarget <UnityEngine.UI.Gradient>().gradientTop; sd.bottomColor = element.GetTarget <UnityEngine.UI.Gradient>().gradientBottom; } }
public override bool ShowState(Element element, ElementStateData sc, int index) { GUILayout.BeginVertical("box"); bool change = ShowVector2(ref sc.vector2Min, "Min") || ShowVector2(ref sc.vector2Max, "Max"); GUILayout.EndVertical(); return(change); }
public override void Set(Element element, int index) { if (element.target != null) { T target = element.GetTarget <T>(); ElementStateData esd = element.stateData[index]; if (esd.isSmooth) { SmoothData sd = new SmoothData(); InitBySmooth(target, sd); esd.AddFrameUpdate((object p) => { if (target == null) { return(false); } #if UNITY_EDITOR if (!Application.isPlaying) { sd.esc_timer += 0.011f; } else #endif { float deltaTime = Time.deltaTime; sd.esc_timer += deltaTime; } bool isend = false; float progress = 1f; if (sd.esc_timer >= esd.smoothTime) { isend = true; } else { progress = sd.esc_timer / esd.smoothTime; } SetBySmooth(target, sd, esd, progress); #if UNITY_EDITOR EditorUtility.SetDirty(target); #endif return(!isend); }, null); } else { SetBySmooth(target, null, esd, -1f); } #if UNITY_EDITOR EditorUtility.SetDirty(target); #endif } }
public override void Init(Element element, ElementStateData sd) { if (element.target == null) { return; } sd.vector2Min = element.GetTarget <RectTransform>().anchorMin; sd.vector2Max = element.GetTarget <RectTransform>().anchorMax; }
public void AddState() { int lenght = stateData == null ? 0 : stateData.Length; System.Array.Resize <ElementStateData>(ref stateData, lenght + 1); stateData[lenght] = new ElementStateData(); Agent.Init(this, stateData[lenght]); }
public override void SetBySmooth(Transform target, SmoothData sd, ElementStateData esd, float progress) { if (sd == null) { target.localPosition = esd.vector3; } else { target.localPosition = sd.Get(esd.vector3, progress); } }
public override void SetBySmooth(CanvasGroup target, SmoothData sd, ElementStateData esd, float progress) { if (sd == null) { target.alpha = esd.vector3.x; } else { target.alpha = sd.Get(esd.vector3.x, progress); } }
public override void SetBySmooth(MaskableGraphic target, SmoothData sd, ElementStateData esd, float progress) { if (sd == null) { target.color = esd.color32; } else { target.color = sd.Get(esd.color32, progress); } }
public override void Init(Element element, ElementStateData sd) { if (element.target != null) { StateRoot sr = element.GetTarget <StateRoot>(); if (sr != null) { sd.intValue = sr.currentState; } } }
public override void SetBySmooth(RectTransform target, SmoothData sd, ElementStateData esd, float progress) { if (sd == null) { target.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, esd.vector3.x); } else { target.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, sd.Get(esd.vector3.x, progress)); } }
public override bool ShowState(Element element, ElementStateData sc, int index) { var old = sc.intValue; var str = EditorGUILayout.TextField("Name", sc.strValue); if (GUI.changed) { RegisterUndo(() => { sc.strValue = str; }); } return(sc.intValue != old); }
public override void SetBySmooth(MaskableGraphic target, SmoothData sd, ElementStateData esd, float progress) { if (sd == null) { Color color = target.color; color.a = esd.vector3.x; target.color = color; } else { Color color = target.color; color.a = sd.Get(esd.vector3.x, progress); target.color = color; } }
public override bool ShowState(Element element, ElementStateData sc, int index) { int old = sc.intValue; StateRoot sr = element.GetTarget <StateRoot>(); if (sr == null) { GUI.changed = false; int v = EditorGUILayout.IntField("状态", sc.intValue); if (GUI.changed) { RegisterUndo(() => { sc.intValue = v; }); return(true); } return(false); } else { List <string> olds = new List <string>(); List <int> values = new List <int>(); for (int i = 0; i < sr.states.Length; ++i) { olds.Add(sr.states[i].Name); values.Add(i); } GUI.changed = false; int v = EditorGUILayout.IntPopup("状态", sc.intValue, olds.ToArray(), values.ToArray()); if (GUI.changed) { RegisterUndo(() => { sc.intValue = v; }); } return(sc.intValue != old); } }
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 override bool ShowState(Element element, ElementStateData sc, int index) { sc.obj = EditorGUILayout.ObjectField(sc.obj, typeof(Sprite), true); return(false); }
public abstract void SetBySmooth(T target, SmoothData sd, ElementStateData esd, float progress);
public override bool ShowState(Element element, ElementStateData sc, int index) { return(ShowColor32(ref sc.color32, "颜色")); }
public override bool ShowState(Element element, ElementStateData sc, int index) { return(ShowSliderFloat(ref sc.vector3, "透明", 0, 1)); }
public override void Init(Element element, ElementStateData sd) { sd.strValue = ""; }
public override bool ShowState(Element element, ElementStateData sc, int index) { return(ShowVector3(ref sc.vector3, "位置")); }