Example #1
0
 public override void Init(Element element, ElementStateData sd)
 {
     if (element.target != null)
     {
         sd.obj = element.GetTarget <Text>().font;
     }
 }
Example #2
0
 public override void Init(Element element, ElementStateData sd)
 {
     if (element.target != null)
     {
         sd.strValue = element.GetTarget <Text>().text;
     }
 }
Example #3
0
        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);
        }
Example #4
0
 public override void Init(Element element, ElementStateData sd)
 {
     if (element.target != null)
     {
         sd.isEnable = element.GetTarget <GameObject>().activeSelf;
     }
 }
Example #5
0
 public override void Init(Element element, ElementStateData sd)
 {
     if (element.target != null)
     {
         sd.vector3 = element.GetTarget <Transform>().localPosition;
     }
 }
Example #6
0
 public override void Init(Element element, ElementStateData sd)
 {
     if (element.target != null)
     {
         sd.vector3.x = element.GetTarget <RectTransform>().rect.width;
     }
 }
Example #7
0
 public override void Init(Element element, ElementStateData sd)
 {
     if (element.target != null)
     {
         sd.vector3.x = element.GetTarget <CanvasGroup>().alpha;
     }
 }
Example #8
0
 public override void Init(Element element, ElementStateData sd)
 {
     if (element.target != null)
     {
         sd.color32 = element.GetTarget <MaskableGraphic>().color;
     }
 }
Example #9
0
 public override void Init(Element element, ElementStateData sd)
 {
     if (element.target != null)
     {
         sd.obj = element.GetTarget <Image>().sprite;
     }
 }
Example #10
0
 public override void Init(Element element, ElementStateData sd)
 {
     if (element.target != null)
     {
         Graphic graphic = element.GetTarget <Graphic>();
         sd.obj = GetGraphicMaterial(graphic);
     }
 }
Example #11
0
 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;
     }
 }
Example #12
0
        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);
        }
Example #13
0
        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
            }
        }
Example #14
0
 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;
 }
Example #15
0
        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]);
        }
Example #16
0
 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);
     }
 }
Example #17
0
 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);
     }
 }
Example #18
0
 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);
     }
 }
Example #19
0
 public override void Init(Element element, ElementStateData sd)
 {
     if (element.target != null)
     {
         StateRoot sr = element.GetTarget <StateRoot>();
         if (sr != null)
         {
             sd.intValue = sr.currentState;
         }
     }
 }
Example #20
0
 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));
     }
 }
Example #21
0
        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);
        }
Example #22
0
 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;
     }
 }
Example #23
0
        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);
            }
        }
Example #24
0
        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);
        }
Example #25
0
        public override bool ShowState(Element element, ElementStateData sc, int index)
        {
            sc.obj = EditorGUILayout.ObjectField(sc.obj, typeof(Sprite), true);

            return(false);
        }
Example #26
0
 public abstract void SetBySmooth(T target, SmoothData sd, ElementStateData esd, float progress);
Example #27
0
 public override bool ShowState(Element element, ElementStateData sc, int index)
 {
     return(ShowColor32(ref sc.color32, "颜色"));
 }
Example #28
0
 public override bool ShowState(Element element, ElementStateData sc, int index)
 {
     return(ShowSliderFloat(ref sc.vector3, "透明", 0, 1));
 }
Example #29
0
 public override void Init(Element element, ElementStateData sd)
 {
     sd.strValue = "";
 }
Example #30
0
 public override bool ShowState(Element element, ElementStateData sc, int index)
 {
     return(ShowVector3(ref sc.vector3, "位置"));
 }