Exemplo n.º 1
0
        public override void OnInspectorGUI()
        {
            GUILayout.Space(6f);
            TweenKitEditorTools.SetLabelWidth(120f);

            TweenOrthoSize tw = target as TweenOrthoSize;

            GUI.changed = false;

            float from = EditorGUILayout.FloatField("From", tw.from);
            float to   = EditorGUILayout.FloatField("To", tw.to);

            if (from < 0f)
            {
                from = 0f;
            }
            if (to < 0f)
            {
                to = 0f;
            }

            if (GUI.changed)
            {
                TweenKitEditorTools.RegisterUndo("Tween Change", tw);
                tw.from = from;
                tw.to   = to;
                TweenKitTools.SetDirty(tw);
            }

            DrawCommonProperties();
        }
Exemplo n.º 2
0
        protected void DrawCommonProperties()
        {
            UITweener tw = target as UITweener;

            if (TweenKitEditorTools.DrawHeader("Tweener"))
            {
                TweenKitEditorTools.BeginContents();
                TweenKitEditorTools.SetLabelWidth(110f);

                GUI.changed = false;

                UITweener.Style style = (UITweener.Style)EditorGUILayout.EnumPopup("Play Style", tw.style);
                AnimationCurve  curve = EditorGUILayout.CurveField("Animation Curve", tw.animationCurve, GUILayout.Width(170f), GUILayout.Height(62f));
                //UITweener.Method method = (UITweener.Method)EditorGUILayout.EnumPopup("Play Method", tw.method);

                GUILayout.BeginHorizontal();
                float dur = EditorGUILayout.FloatField("Duration", tw.duration, GUILayout.Width(170f));
                GUILayout.Label("seconds");
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                float del = EditorGUILayout.FloatField("Start Delay", tw.delay, GUILayout.Width(170f));
                GUILayout.Label("seconds");
                GUILayout.EndHorizontal();

                int  tg = EditorGUILayout.IntField("Tween Group", tw.tweenGroup, GUILayout.Width(170f));
                bool ts = EditorGUILayout.Toggle("Ignore TimeScale", tw.ignoreTimeScale);
                bool fx = EditorGUILayout.Toggle("Use Fixed Update", tw.useFixedUpdate);

                if (GUI.changed)
                {
                    TweenKitEditorTools.RegisterUndo("Tween Change", tw);
                    tw.animationCurve = curve;
                    //tw.method = method;
                    tw.style           = style;
                    tw.ignoreTimeScale = ts;
                    tw.tweenGroup      = tg;
                    tw.duration        = dur;
                    tw.delay           = del;
                    tw.useFixedUpdate  = fx;
                    TweenKitTools.SetDirty(tw);
                }
                TweenKitEditorTools.EndContents();
            }

            TweenKitEditorTools.SetLabelWidth(80f);
            TweenKitEditorTools.DrawEvents("On Finished", tw, tw.onFinished);
        }
Exemplo n.º 3
0
        public override void OnInspectorGUI()
        {
            GUILayout.Space(6f);
            TweenKitEditorTools.SetLabelWidth(120f);

            TweenFOV tw = target as TweenFOV;

            GUI.changed = false;

            float from = EditorGUILayout.Slider("From", tw.from, 1f, 180f);
            float to   = EditorGUILayout.Slider("To", tw.to, 1f, 180f);

            if (GUI.changed)
            {
                TweenKitEditorTools.RegisterUndo("Tween Change", tw);
                tw.from = from;
                tw.to   = to;
                TweenKitTools.SetDirty(tw);
            }

            DrawCommonProperties();
        }
Exemplo n.º 4
0
        public override void OnInspectorGUI()
        {
            GUILayout.Space(6f);
            TweenKitEditorTools.SetLabelWidth(120f);

            TweenScale tw = target as TweenScale;

            GUI.changed = false;

            Vector3 from = EditorGUILayout.Vector3Field("From", tw.from);
            Vector3 to   = EditorGUILayout.Vector3Field("To", tw.to);

            if (GUI.changed)
            {
                TweenKitEditorTools.RegisterUndo("Tween Change", tw);
                tw.from = from;
                tw.to   = to;
                TweenKitTools.SetDirty(tw);
            }

            DrawCommonProperties();
        }
Exemplo n.º 5
0
        public override void OnInspectorGUI()
        {
            GUILayout.Space(6f);
            TweenKitEditorTools.SetLabelWidth(120f);

            TweenRotation tw = target as TweenRotation;

            GUI.changed = false;

            Vector3 from = EditorGUILayout.Vector3Field("From", tw.from);
            Vector3 to   = EditorGUILayout.Vector3Field("To", tw.to);
            var     quat = EditorGUILayout.Toggle("Quaternion", tw.quaternionLerp);

            if (GUI.changed)
            {
                TweenKitEditorTools.RegisterUndo("Tween Change", tw);
                tw.from           = from;
                tw.to             = to;
                tw.quaternionLerp = quat;
                TweenKitTools.SetDirty(tw);
            }

            DrawCommonProperties();
        }
        /// <summary>
        /// Draw an editor field for the Unity Delegate.
        /// </summary>

        public static bool Field(Object undoObject, EventDelegate del, bool removeButton, bool minimalistic)
        {
            if (del == null)
            {
                return(false);
            }
            bool prev = GUI.changed;

            GUI.changed = false;
            bool          retVal = false;
            MonoBehaviour target = del.target;
            bool          remove = false;

            if (removeButton && (del.target != null || del.isValid))
            {
                if (!minimalistic)
                {
                    TweenKitEditorTools.SetLabelWidth(82f);
                }

                if (del.target == null && del.isValid)
                {
                    EditorGUILayout.LabelField("Notify", del.ToString());
                }
                else
                {
                    target = EditorGUILayout.ObjectField("Notify", del.target, typeof(MonoBehaviour), true) as MonoBehaviour;
                }

                GUILayout.Space(-18f);
                GUILayout.BeginHorizontal();
                GUILayout.Space(70f);

                if (GUILayout.Button("", "ToggleMixed", GUILayout.Width(20f), GUILayout.Height(16f)))
                {
                    target = null;
                    remove = true;
                }
                GUILayout.EndHorizontal();
            }
            else
            {
                target = EditorGUILayout.ObjectField("Notify", del.target, typeof(MonoBehaviour), true) as MonoBehaviour;
            }

            if (remove)
            {
                TweenKitEditorTools.RegisterUndo("Delegate Selection", undoObject);
                del.Clear();
                TweenKitTools.SetDirty(undoObject);
            }
            else if (del.target != target)
            {
                TweenKitEditorTools.RegisterUndo("Delegate Selection", undoObject);
                del.target = target;
                TweenKitTools.SetDirty(undoObject);
            }

            if (del.target != null && del.target.gameObject != null)
            {
                GameObject   go   = del.target.gameObject;
                List <Entry> list = GetMethods(go);

                int      index  = 0;
                string[] names  = PropertyReferenceDrawer.GetNames(list, del.ToString(), out index);
                int      choice = 0;

                GUILayout.BeginHorizontal();
                choice = EditorGUILayout.Popup("Method", index, names);
                TweenKitEditorTools.DrawPadding();
                GUILayout.EndHorizontal();

                if (choice > 0 && choice != index)
                {
                    Entry entry = list[choice - 1];
                    TweenKitEditorTools.RegisterUndo("Delegate Selection", undoObject);
                    del.target     = entry.target as MonoBehaviour;
                    del.methodName = entry.name;
                    TweenKitTools.SetDirty(undoObject);
                    retVal = true;
                }

                GUI.changed = false;
                EventDelegate.Parameter[] ps = del.parameters;

                if (ps != null)
                {
                    for (int i = 0; i < ps.Length; ++i)
                    {
                        EventDelegate.Parameter param = ps[i];
                        Object obj = EditorGUILayout.ObjectField("   Arg " + i, param.obj, typeof(Object), true);

                        if (GUI.changed)
                        {
                            GUI.changed = false;
                            param.obj   = obj;
                            TweenKitTools.SetDirty(undoObject);
                        }

                        if (obj == null)
                        {
                            continue;
                        }

                        GameObject  selGO = null;
                        System.Type type  = obj.GetType();
                        if (type == typeof(GameObject))
                        {
                            selGO = obj as GameObject;
                        }
                        else if (type.IsSubclassOf(typeof(Component)))
                        {
                            selGO = (obj as Component).gameObject;
                        }

                        if (selGO != null)
                        {
                            // Parameters must be exact -- they can't be converted like property bindings
                            PropertyReferenceDrawer.filter     = param.expectedType;
                            PropertyReferenceDrawer.canConvert = false;
                            List <PropertyReferenceDrawer.Entry> ents = PropertyReferenceDrawer.GetProperties(selGO, true, false);

                            int      selection;
                            string[] props = GetNames(ents, TweenKitTools.GetFuncName(param.obj, param.field), out selection);

                            GUILayout.BeginHorizontal();
                            int newSel = EditorGUILayout.Popup(" ", selection, props);
                            TweenKitEditorTools.DrawPadding();
                            GUILayout.EndHorizontal();

                            if (GUI.changed)
                            {
                                GUI.changed = false;

                                if (newSel == 0)
                                {
                                    param.obj   = selGO;
                                    param.field = null;
                                }
                                else
                                {
                                    param.obj   = ents[newSel - 1].target;
                                    param.field = ents[newSel - 1].name;
                                }
                                TweenKitTools.SetDirty(undoObject);
                            }
                        }
                        else if (!string.IsNullOrEmpty(param.field))
                        {
                            param.field = null;
                            TweenKitTools.SetDirty(undoObject);
                        }

                        PropertyReferenceDrawer.filter     = typeof(void);
                        PropertyReferenceDrawer.canConvert = true;
                    }
                }
            }
            else
            {
                retVal = GUI.changed;
            }
            GUI.changed = prev;
            return(retVal);
        }