Beispiel #1
0
    bool DrawToggleContent(TweenPRS _tw, TweenPRS.PRSType _type)
    {
        GUI.changed = false;

        string name = "";

        if (_type == TweenPRS.PRSType.Pos)
        {
            name = " TweenPosition";
        }
        else if (_type == TweenPRS.PRSType.Rot)
        {
            name = " TweenRotation";
        }
        else
        {
            name = " TweenScale";
        }

        bool enablePRS = _tw.isEnable(_type);

        enablePRS = EditorGUILayout.ToggleLeft(name, enablePRS);

        if (GUI.changed == true)
        {
            UIEditorTools.RegisterUndo("Tween Change", _tw);
            _tw.setEnable(_type, enablePRS);
            UnityEditor.EditorUtility.SetDirty(_tw);
        }

        return(enablePRS);
    }
Beispiel #2
0
    public override void OnInspectorGUI()
    {
        GUILayout.Space(6f);
        UIEditorTools.SetLabelWidth(110f);

        base.OnInspectorGUI();

        DrawCommonProperties();
    }
Beispiel #3
0
    protected void DrawCommonProperties(TweenPRS _tw, TweenPRS.PRSType _type)
    {
        if (UIEditorTools.DrawHeader("Tweener", "Tweener_" + _type.ToString()))
        {
            UIEditorTools.BeginContents();
            UIEditorTools.SetLabelWidth(110f);

            GUI.changed = false;

            TweenPRS.Style style = _tw.GetStyle(_type);
            style = (TweenPRS.Style)EditorGUILayout.EnumPopup("Play Style", style);

            AnimationCurve curve = _tw.GetAnimationCurve(_type);
            curve = EditorGUILayout.CurveField("Animation Curve", curve,
                                               GUILayout.Width(170), GUILayout.Height(62));

            bool useSpeed = _tw.isSpeed(_type);
            if (style == TweenPRS.Style.Once && _type == TweenPRS.PRSType.Pos)
            {
                useSpeed = EditorGUILayout.ToggleLeft("Use Speed", useSpeed);
            }
            else
            {
                useSpeed = false;
            }

            GUILayout.BeginHorizontal();
            float dur = _tw.GetDuration(_type);

            string str = style == TweenPRS.Style.Once ? (useSpeed ? "Speed" : "Duration") : "Duration";
            dur = EditorGUILayout.FloatField(str, dur, GUILayout.Width(170f));
            str = style == TweenPRS.Style.Once ? (useSpeed ? "unit/s" : "seconds") : "seconds";
            GUILayout.Label(str);
            GUILayout.EndHorizontal();


            if (GUI.changed == true)
            {
                UIEditorTools.RegisterUndo("Tween Change", _tw);

                _tw.SetAnimationCurve(_type, curve);
                _tw.SetDuration(_type, dur);
                _tw.SetStyle(_type, style);
                _tw.setEnableSpeed(_type, useSpeed);

                UnityEditor.EditorUtility.SetDirty(_tw);
            }

            UIEditorTools.EndContents();
        }

        UIEditorTools.SetLabelWidth(80f);
        UIEditorTools.DrawEvents("On Finished", "On Finished_" + _type.ToString(), _tw, _tw.GetOnFinished(_type));
    }
Beispiel #4
0
    /// <summary>
    /// Draw a list of fields for the specified list of delegates.
    /// </summary>

    static public void DrawEvents(string text, string key, Object undoObject, List <EventDelegate> list, string noTarget, string notValid)
    {
        if (!UIEditorTools.DrawHeader(text, key))
        {
            return;
        }

        UIEditorTools.BeginContents();
        EventDelegateEditor.Field(undoObject, list, notValid, notValid);
        UIEditorTools.EndContents();
    }
Beispiel #5
0
    public override void OnInspectorGUI()
    {
        GUILayout.Space(6f);
        UIEditorTools.SetLabelWidth(120f);

        TweenPRS tw = target as TweenPRS;

        DrawTweenContents(tw, TweenPRS.PRSType.Pos);

        DrawTweenContents(tw, TweenPRS.PRSType.Rot);

        DrawTweenContents(tw, TweenPRS.PRSType.Scale);
    }
Beispiel #6
0
    /// <summary>
    /// Draw a list of fields for the specified list of delegates.
    /// </summary>

    static public void DrawActions(string text, string key, Object undoObject, ref float distance, List <EventDelegate> list, string noTarget, string notValid)
    {
        if (!UIEditorTools.DrawHeader(text, key))
        {
            return;
        }

        UIEditorTools.BeginContents();
        GUILayout.Space(5);
        distance = EditorGUILayout.FloatField("Trigger Dist", distance);
        GUILayout.Space(5);
        EventDelegateEditor.Field(undoObject, list, notValid, notValid);
        GUILayout.Space(5);
        UIEditorTools.EndContents();
    }
Beispiel #7
0
    /// <summary>
    /// Draw a list of fields for the specified list of delegates.
    /// </summary>

    static public void DrawActions(string text, string key, Object undoObject, ref Collider collider, List <EventDelegate> list, string noTarget, string notValid)
    {
        if (!UIEditorTools.DrawHeader(text, key))
        {
            return;
        }

        UIEditorTools.BeginContents();
        GUILayout.Space(5);
        collider = EditorGUILayout.ObjectField("Trigger Rgn", collider, typeof(Collider), true) as Collider;
        GUILayout.Space(5);
        EventDelegateEditor.Field(undoObject, list, notValid, notValid);
        GUILayout.Space(5);
        UIEditorTools.EndContents();
    }
Beispiel #8
0
    bool DrawOffsetContent(TweenPRS _tw, TweenPRS.PRSType _type)
    {
        GUI.changed = false;
        bool enableOffset = _tw.isEnableOffset(_type);

        enableOffset = EditorGUILayout.ToggleLeft(" Enable Offset", enableOffset);

        if (GUI.changed == true)
        {
            UIEditorTools.RegisterUndo("Tween Change", _tw);
            _tw.setEnableOffset(_type, enableOffset);
            UnityEditor.EditorUtility.SetDirty(_tw);
        }

        return(enableOffset);
    }
Beispiel #9
0
    /// <summary>
    /// Convert the specified list of delegate entries into a string array.
    /// </summary>

    static string[] GetNames(List <Entry> list, string choice, out int index)
    {
        index = 0;
        string[] names = new string[list.Count + 1];
        names[0] = "<GameObject>";

        for (int i = 0; i < list.Count;)
        {
            Entry  ent = list[i];
            string del = UIEditorTools.GetFuncName(ent.target, ent.name);
            names[++i] = del;
            if (index == 0 && string.Equals(del, choice))
            {
                index = i;
            }
        }
        return(names);
    }
Beispiel #10
0
    /// <summary>
    /// Convert the specified list of delegate entries into a string array.
    /// </summary>

    static public string[] GetNames(List <Entry> list, string choice, out int index)
    {
        index = 0;
        string[] names = new string[list.Count + 2];
        names[0] = string.IsNullOrEmpty(choice) ? "<Choose>" : choice;
        names[1] = "";

        for (int i = 0; i < list.Count;)
        {
            Entry  ent = list[i];
            string del = UIEditorTools.GetFuncName(ent.target, ent.name);
            names[++i + 1] = del;
            if (index == 0 && string.Equals(del, choice))
            {
                index = i;
            }
        }
        return(names);
    }
Beispiel #11
0
    void DrawTweenContents(TweenPRS _tw, TweenPRS.PRSType _type)
    {
        if (DrawToggleContent(_tw, _type))
        {
            UIEditorTools.BeginContents();
            UIEditorTools.SetLabelWidth(110f);

            GUI.changed = false;

            bool enableOffset = DrawOffsetContent(_tw, _type);
            DrawTweenInfo(_tw, _type, enableOffset);

            UIEditorTools.BeginContents();
            UIEditorTools.SetLabelWidth(100f);
            DrawCommonProperties(_tw, _type);
            UIEditorTools.EndContents();

            UIEditorTools.EndContents();
        }
    }
Beispiel #12
0
    static void MassBuildQPrefab()
    {
        string output   = "";
        var    oldScene = EditorSceneManager.GetActiveScene().path;
        Dictionary <int, List <GameObjectDifference> > result = GetDifference();

        EditorUtility.DisplayProgressBar("Mass Build QPrefab", "Building", 0);
        for (int iter = 0; iter < result[0].Count; ++iter)
        {
            string path = Application.dataPath.Substring(0, Application.dataPath.IndexOf("Assets")) + "Assets/Scripts/UI/Prefab/" + result[0][iter].q_UI.name + ".unity";

            if (!System.IO.File.Exists(path))
            {
                output += "Unable to Open Scene " + result[0][iter].q_UI.name + "\n";
                continue;
            }

            var scene = EditorSceneManager.OpenScene(path);

            var go = GameObject.FindObjectOfType <UI_VersionNumber>();
            if (go != null)
            {
                UIEditorTools.Create_QUI_Prefab(go.gameObject);
                output += "Q prefab made successfully " + result[0][iter].q_UI.name + "\n";
            }
            else
            {
                output += "Unable to Find Object with UI_VersionNumber " + result[0][iter].q_UI.name + "\n";
            }

            EditorUtility.DisplayProgressBar("Mass Build QPrefab", "Building", iter / result[0].Count);
        }
        EditorSceneManager.OpenScene(oldScene);
        EditorUtility.ClearProgressBar();
        foreach (var obj in result[1])
        {
            output += "Unable to Find Scene " + obj.p_UI.name + "\n";
        }
        Debug.Log(output);
    }
Beispiel #13
0
    protected void DrawCommonProperties()
    {
        Tweener tw = target as Tweener;

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

            GUI.changed = false;

            Tweener.Style  style = (Tweener.Style)EditorGUILayout.EnumPopup("Play Style", tw.m_Style);
            AnimationCurve curve = EditorGUILayout.CurveField("Animation Curve", tw.m_AnimationCurve,
                                                              GUILayout.Width(170), GUILayout.Height(62));

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


            if (GUI.changed == true)
            {
                UIEditorTools.RegisterUndo("Tween Change", tw);

                tw.m_AnimationCurve = curve;
                tw.m_Style          = style;
                tw.Duration         = dur;

                UnityEditor.EditorUtility.SetDirty(tw);
            }

            UIEditorTools.EndContents();
        }

        UIEditorTools.SetLabelWidth(80f);
        UIEditorTools.DrawEvents("On Finished", tw, tw.onFinished);
    }
Beispiel #14
0
    public override void OnInspectorGUI()
    {
        GUILayout.Space(6f);
        UIEditorTools.SetLabelWidth(120f);

        TweenColor tw = target as TweenColor;

        GUI.changed = false;

        Color from = EditorGUILayout.ColorField("From", tw.From);
        Color to   = EditorGUILayout.ColorField("To", tw.To);

        if (GUI.changed)
        {
            UIEditorTools.RegisterUndo("Tween Change", tw);
            tw.From = from;
            tw.To   = to;

            UnityEditor.EditorUtility.SetDirty(tw);
        }

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

    static public bool Field(Object undoObject, EventDelegate del, bool removeButton)
    {
        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 (del.target == null && del.isValid)
            {
                EditorGUILayout.LabelField("Notify", del.ToString());
            }
            else
            {
                target = EditorGUILayout.ObjectField("Notify", del.target, typeof(MonoBehaviour), true) as MonoBehaviour;
            }

            GUILayout.Space(-20f);
            GUILayout.BeginHorizontal();
            GUILayout.Space(64f);

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

        if (remove)
        {
            UIEditorTools.RegisterUndo("Delegate Selection", undoObject);
            del.Clear();
            EditorUtility.SetDirty(undoObject);
        }
        else if (del.target != target)
        {
            UIEditorTools.RegisterUndo("Delegate Selection", undoObject);
            del.target = target;
            EditorUtility.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);
            GUILayout.Space(18f);
            GUILayout.EndHorizontal();

            if (choice > 0 && choice != index)
            {
                //Entry entry = list[choice - 1];
                Entry entry = list[choice - 2];
                UIEditorTools.RegisterUndo("Delegate Selection", undoObject);
                del.target     = entry.target as MonoBehaviour;
                del.methodName = entry.name;
                EditorUtility.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 = param.obj as Object;
                    //if (_obj == null)
                    //    continue;

                    Object obj = EditorGUILayout.ObjectField("   Arg " + i, param.obj, typeof(Object), true);

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

                    if (obj == null)
                    {
                        continue;
                    }

                    System.Type type = obj.GetType();

                    GameObject selGO = null;
                    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, UIEditorTools.GetFuncName(param.obj, param.field), out selection);

                        GUILayout.BeginHorizontal();
                        int newSel = EditorGUILayout.Popup(" ", selection, props);
                        GUILayout.Space(18f);
                        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;
                            }
                            EditorUtility.SetDirty(undoObject);
                        }
                    }
                    else if (!string.IsNullOrEmpty(param.field))
                    {
                        param.field = null;
                        EditorUtility.SetDirty(undoObject);
                    }

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

        GUI.changed = prev;
        return(retVal);
    }
Beispiel #16
0
 public static void CreateProgrammerUIScene()
 {
     UIEditorTools.Create_QUI_Scene();
 }
Beispiel #17
0
    public override void OnInspectorGUI()
    {
        GUILayout.Space(6f);
        UIEditorTools.SetLabelWidth(120f);

        TweenHeight tw = target as TweenHeight;

        GUI.changed = false;

        bool enableOffset = EditorGUILayout.ToggleLeft("Enable Offset ", tw.EnableOffset);

        if (GUI.changed)
        {
            UIEditorTools.RegisterUndo("Tween Change", tw);
            tw.EnableOffset = enableOffset;
            UnityEditor.EditorUtility.SetDirty(tw);
        }

        GUI.changed = false;
        int from = 0, to = 0, offset = 0;

        GUILayout.BeginHorizontal();
        GUILayout.Space(20f);
        GUILayout.BeginVertical();
        GUILayout.Space(2f);

        if (!enableOffset)
        {
            from = EditorGUILayout.IntField("From", (int)tw.From);
            to   = EditorGUILayout.IntField("To", (int)tw.To);
        }
        else
        {
            offset = EditorGUILayout.IntField("Offset", (int)tw.Offset);
        }

        GUILayout.EndHorizontal();
        GUILayout.Space(20f);
        GUILayout.EndVertical();
        GUILayout.Space(2f);

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

        if (GUI.changed)
        {
            UIEditorTools.RegisterUndo("Tween Change", tw);
            if (!enableOffset)
            {
                tw.From = from;
                tw.To   = to;
            }
            else
            {
                tw.Offset = offset;
            }

            UnityEditor.EditorUtility.SetDirty(tw);
        }

        DrawCommonProperties();
    }
Beispiel #18
0
    bool DrawTweenInfo(TweenPRS _tw, TweenPRS.PRSType _type, bool _offset)
    {
        GUILayout.BeginHorizontal();
        GUILayout.Space(20f);
        GUILayout.BeginVertical();
        GUILayout.Space(2f);

        GUI.changed = false;


        Vector3 from   = _tw.GetFrom(_type);
        Vector3 to     = _tw.GetTo(_type);
        Vector3 offset = _tw.GetOffset(_type);

        if (!_offset)
        {
            if (_type == TweenPRS.PRSType.Pos)
            {
                Vector2 tmpFrom = new Vector2(from.x, from.y);
                Vector2 tmpTo   = new Vector2(to.x, to.y);
                tmpFrom = EditorGUILayout.Vector2Field("From", tmpFrom);
                tmpTo   = EditorGUILayout.Vector2Field("To", tmpTo);

                from = new Vector3(tmpFrom.x, tmpFrom.y, 0);
                to   = new Vector3(tmpTo.x, tmpTo.y, 0);
            }
            else
            {
                from = EditorGUILayout.Vector3Field("From", from);
                to   = EditorGUILayout.Vector3Field("To", to);
            }
        }
        else
        {
            if (_type == TweenPRS.PRSType.Pos)
            {
                Vector2 tmp = new Vector2(offset.x, offset.y);
                tmp    = EditorGUILayout.Vector2Field("Offset", tmp);
                offset = new Vector3(tmp.x, tmp.y, 0);
            }
            else
            {
                offset = EditorGUILayout.Vector3Field("Offset", offset);
            }
        }

        if (GUI.changed == true)
        {
            UIEditorTools.RegisterUndo("Tween Change", _tw);

            if (!_offset)
            {
                _tw.SetFrom(_type, from);
                _tw.SetTo(_type, to);
            }
            else
            {
                _tw.SetOffset(_type, offset);
            }

            UnityEditor.EditorUtility.SetDirty(_tw);
        }

        GUILayout.EndHorizontal();
        GUILayout.Space(20f);
        GUILayout.EndVertical();
        GUILayout.Space(2f);

        return(true);
    }
Beispiel #19
0
 public static void CreateProgrammerUIPrefab()
 {
     UIEditorTools.Create_QUI_Prefab(Selection.activeGameObject as GameObject);
 }
Beispiel #20
0
 public static void CreateUIPrefab()
 {
     UIEditorTools.CreateUIPrefab();
 }