예제 #1
0
        public override void DrawCustomInspector()
        {
            if (rootGraph.eventboards.Count == 0)
            {
                EditorGUILayout.HelpBox("No eventboard available in this graph", MessageType.Info);
                return;
            }


            var eb = rootGraph.eventboards.Keys.Select(x => x.ToString()).ToArray();


            if (lastSelectedEB != selectedEB)
            {
                RegisterNode();
            }


            var options = new string[rootGraph.eventboards.Keys.Count];
            var index   = 0;

            foreach (var board in rootGraph.eventboards.Keys)
            {
                if (rootGraph.eventboards[board].eventboard == null)
                {
                    options[index] = "empty";
                }
                else
                {
                    options[index] = rootGraph.eventboards[board].eventboard.name;
                }

                index++;
            }

            if (eventBoardPopup == null)
            {
                eventBoardPopup = new PopUps.GenericStringPopup(options, out selectedEB);
            }

            EditorGUI.BeginChangeCheck();
            using (new GUILayout.VerticalScope(editorSkin.GetStyle("Box")))
            {
                GUILayout.Label("Eventboard:");

                //selectedEB = EditorGUILayout.Popup(selectedEB, ebNames, EditorStyles.popup);

                var _rect = GUILayoutUtility.GetLastRect();
                if (GUILayout.Button(options[selectedEB]))
                {
                    PopupWindow.Show(_rect, eventBoardPopup);
                }
            }

            selectedEB = eventBoardPopup._selected;

            if (eb == null || eb.Length == 0)
            {
                EditorGUILayout.HelpBox("Create or assign a new eventboard", MessageType.Info);
                return;
            }


            if (selectedEB < eb.Length)
            {
                if (rootGraph.eventboards[Guid.Parse(eb[selectedEB])].eventboard != null)
                {
                    if (editor == null || rootGraph.eventboards[Guid.Parse(eb[selectedEB])].eventboard != eventBoard)
                    {
                        eventBoard = rootGraph.eventboards[Guid.Parse(eb[selectedEB])].eventboard;

                        editor = UnityEditor.Editor.CreateEditor(eventBoard) as EventBoardEditor;
                    }

                    if (editor == null)
                    {
                        return;
                    }


                    editor.DrawNodeInspector(eventBoard, selectedEventID, out selectedEventID, out selectedEventIDInt);
                }
            }

            if (EditorGUI.EndChangeCheck())
            {
                RegisterNode();
            }


            // EVENT PARAMETERS
            ///////////////////

            if (eventBoard != null && eventBoard.events.Keys.Count > 0)
            {
                GUILayout.Label("Send event parameters:");

                Guid _id = Guid.Empty;

                if (Guid.TryParse(selectedEventID, out _id))
                {
                    if (eventBoard.events.ContainsKey(Guid.Parse(selectedEventID)))
                    {
                        foreach (var ep in eventBoard.events[Guid.Parse(selectedEventID)].parameters.Keys)
                        {
                            var _exists = false;
                            foreach (var p in parameters.Keys)
                            {
                                if (p == ep)
                                {
                                    _exists = true;
                                }
                            }
                            if (!_exists)
                            {
                                Refresh();
                            }
                        }

                        var _parameterKeyList = parameters.Keys.ToList();
                        foreach (var p in _parameterKeyList)
                        {
                            var _exists = false;
                            foreach (var ep in eventBoard.events[Guid.Parse(selectedEventID)].parameters.Keys)
                            {
                                if (p == ep)
                                {
                                    _exists = true;
                                }
                            }
                            if (!_exists)
                            {
                                parameters.Remove(p);
                            }
                        }

                        foreach (var p in parameters.Keys)
                        {
                            using (new GUILayout.HorizontalScope(editorSkin.GetStyle("Box")))
                            {
                                //GUILayout.Label(parameters[p].name);
                                FRVariableGUIUtility.DrawVariable(parameters[p].name, parameters[p], this, false, editorSkin);
                            }
                        }
                    }
                }
            }
        }
예제 #2
0
        public override void DrawCustomInspector()
        {
            base.DrawCustomInspector();

            using (new GUILayout.VerticalScope("Box"))
            {
                GUILayout.Label("Tween ID:", "boldLabel");
                tweenID = GUILayout.TextField(tweenID, GUILayout.Height(18));
            }

            using (new GUILayout.VerticalScope("Box"))
            {
                GUILayout.Label("On Tween Complete Event", "boldLabel");

                useOnTweenCompleteEvent = GUILayout.Toggle(useOnTweenCompleteEvent, "Enable");

                if (useOnTweenCompleteEvent)
                {
                    var eb     = rootGraph.eventboards.Keys.Select(x => x.ToString()).ToArray();
                    var ebName = rootGraph.eventboards.Values.Select(x => x.eventboard != null ? x.eventboard.name.ToString() : "empty").ToArray();

                    GUILayout.Label("Eventboard:");

                    selectedEB = EditorGUILayout.Popup(selectedEB, ebName);

                    if (eb != null || eb.Length > 0)
                    {
                        if (selectedEB < eb.Length)
                        {
                            if (rootGraph.eventboards[Guid.Parse(eb[selectedEB])].eventboard != null)
                            {
                                if (editor == null || rootGraph.eventboards[Guid.Parse(eb[selectedEB])].eventboard != eventBoard)
                                {
                                    eventBoard = rootGraph.eventboards[Guid.Parse(eb[selectedEB])].eventboard;

                                    editor = UnityEditor.Editor.CreateEditor(eventBoard) as EventBoardEditor;
                                }

                                if (editor != null)
                                {
                                    editor.DrawNodeInspector(eventBoard, selectedEventID, out selectedEventID, out selectedEventIDInt);
                                }
                            }
                        }
                    }
                    else
                    {
                        EditorGUILayout.HelpBox("Create or assign a new eventboard", MessageType.Info);
                    }
                }
            }


            GUILayout.Label("Tween Sequence:");

            using (new GUILayout.VerticalScope("TextArea"))
            {
                if (GUILayout.Button("Add"))
                {
                    tweenSequence.Add(new Sequence());
                }

                var _totalDuration = 0f;

                for (int s = 0; s < tweenSequence.Count; s++)
                {
                    using (new GUILayout.VerticalScope("Box"))
                    {
                        using (new GUILayout.HorizontalScope("Toolbar"))
                        {
                            if (s - 1 >= 0)
                            {
                                if (tweenSequence[s].tweenState == Sequence.TweenState.append)
                                {
                                    GUILayout.Label("starts at: " + _totalDuration.ToString());
                                }
                                else
                                {
                                    GUILayout.Label("starts at: " + tweenSequence[s].insertTime);
                                }
                            }
                            else
                            {
                                if (tweenSequence[s].tweenState == Sequence.TweenState.append)
                                {
                                    GUILayout.Label("starts at: 0");
                                }
                                else
                                {
                                    GUILayout.Label("starts at: " + tweenSequence[s].insertTime);
                                }
                            }

                            GUILayout.FlexibleSpace();

                            if (GUILayout.Button("<", "ToolbarButton", GUILayout.Width(25)))
                            {
                            }

                            if (GUILayout.Button(">", "ToolbarButton", GUILayout.Width(25)))
                            {
                            }

                            if (GUILayout.Button("x", "ToolbarButton", GUILayout.Width(25)))
                            {
                                tweenSequence.RemoveAt(s);

                                return;
                            }
                        }

                        using (new GUILayout.HorizontalScope())
                        {
                            tweenSequence[s].tweenState = (Sequence.TweenState)EditorGUILayout.EnumPopup("", tweenSequence[s].tweenState, GUILayout.Width(100));

                            if (tweenSequence[s].tweenState == Sequence.TweenState.insert)
                            {
                                tweenSequence[s].insertTime = EditorGUILayout.FloatField(tweenSequence[s].insertTime);
                            }
                        }

                        using (new GUILayout.HorizontalScope())
                        {
                            tweenSequence[s].tweenObject = (Sequence.TweenObject)EditorGUILayout.EnumPopup("", tweenSequence[s].tweenObject, GUILayout.Width(100));

                            switch (tweenSequence[s].tweenObject)
                            {
                            case Sequence.TweenObject.floatValue:
                                var _varFloat = tweenSequence[s].GetType().GetField("floatValue").GetValue(tweenSequence[s]) as FRVariable;
                                FRVariableGUIUtility.DrawVariable("floatValue", _varFloat, this, false, editorSkin);
                                //FRVariableGUIUtility.DrawVariable(tweenSequence[s].GetType().GetField("floatValue"), tweenSequence[s].floatValue, this, editorSkin);
                                break;

                            case Sequence.TweenObject.intValue:
                                var _varInt = tweenSequence[s].GetType().GetField("intValue").GetValue(tweenSequence[s]) as FRVariable;
                                FRVariableGUIUtility.DrawVariable("intValue", _varInt, this, false, editorSkin);
                                //FRVariableGUIUtility.DrawVariable(tweenSequence[s].GetType().GetField("intValue"), tweenSequence[s].intValue, this, editorSkin);
                                break;

                            case Sequence.TweenObject.gameObject:
                                var _varGO = tweenSequence[s].GetType().GetField("gameObject").GetValue(tweenSequence[s]) as FRVariable;
                                FRVariableGUIUtility.DrawVariable("gameObject", _varGO, this, false, editorSkin);
                                //FRVariableGUIUtility.DrawVariable(tweenSequence[s].GetType().GetField("gameObject"), tweenSequence[s].gameObject, this, editorSkin);
                                break;

                            case Sequence.TweenObject.image:
                                var _varImage = tweenSequence[s].GetType().GetField("image").GetValue(tweenSequence[s]) as FRVariable;
                                FRVariableGUIUtility.DrawVariable("image", _varImage, this, false, editorSkin);
                                //FRVariableGUIUtility.DrawVariable(tweenSequence[s].GetType().GetField("image"), tweenSequence[s].image, this, editorSkin);
                                break;

                            case Sequence.TweenObject.rectTransform:
                                var _varRect = tweenSequence[s].GetType().GetField("rectTransform").GetValue(tweenSequence[s]) as FRVariable;
                                FRVariableGUIUtility.DrawVariable("rectTransform", _varRect, this, false, editorSkin);
                                //FRVariableGUIUtility.DrawVariable(tweenSequence[s].GetType().GetField("rectTransform"), tweenSequence[s].rectTransform, this, editorSkin);
                                break;

                            case Sequence.TweenObject.canvasGroup:
                                var _varCG = tweenSequence[s].GetType().GetField("canvasGroup").GetValue(tweenSequence[s]) as FRVariable;
                                FRVariableGUIUtility.DrawVariable("canvasGroup", _varCG, this, false, editorSkin);
                                //FRVariableGUIUtility.DrawVariable(tweenSequence[s].GetType().GetField("canvasGroup"), tweenSequence[s].canvasGroup, this, editorSkin);
                                break;
                            }
                        }


                        using (new GUILayout.HorizontalScope())
                        {
                            switch (tweenSequence[s].tweenObject)
                            {
                            case Sequence.TweenObject.floatValue:

                                tweenSequence[s].tweenMethodVariables = (Sequence.TweenMethodVariables)EditorGUILayout.EnumPopup("", tweenSequence[s].tweenMethodVariables, GUILayout.Width(100));

                                FRVariableGUIUtility.DrawVariable(tweenSequence[s].targetFloat, this, false, editorSkin);

                                break;

                            case Sequence.TweenObject.intValue:

                                tweenSequence[s].tweenMethodVariables = (Sequence.TweenMethodVariables)EditorGUILayout.EnumPopup("", tweenSequence[s].tweenMethodVariables, GUILayout.Width(100));

                                FRVariableGUIUtility.DrawVariable(tweenSequence[s].targetInt, this, false, editorSkin);

                                break;

                            case Sequence.TweenObject.gameObject:
                                tweenSequence[s].tweenMethodTransform = (Sequence.TweenMethodTransform)EditorGUILayout.EnumPopup("", tweenSequence[s].tweenMethodTransform, GUILayout.Width(100));

                                FRVariableGUIUtility.DrawVariable(tweenSequence[s].target, this, false, editorSkin);
                                break;

                            case Sequence.TweenObject.image:
                                tweenSequence[s].tweenMethodImage = (Sequence.TweenMethodImage)EditorGUILayout.EnumPopup("", tweenSequence[s].tweenMethodImage, GUILayout.Width(100));

                                switch (tweenSequence[s].tweenMethodImage)
                                {
                                case Sequence.TweenMethodImage.DOColor:

                                    FRVariableGUIUtility.DrawVariable(tweenSequence[s].targetColor, this, false, editorSkin);
                                    break;

                                default:

                                    FRVariableGUIUtility.DrawVariable(tweenSequence[s].targetFloat, this, false, editorSkin);
                                    break;
                                }


                                break;

                            case Sequence.TweenObject.rectTransform:
                                tweenSequence[s].tweenMethodTransform = (Sequence.TweenMethodTransform)EditorGUILayout.EnumPopup("", tweenSequence[s].tweenMethodTransform, GUILayout.Width(100));
                                //tweenSequence[s].target = EditorGUILayout.Vector3Field("",tweenSequence[s].target);

                                switch (tweenSequence[s].tweenMethodTransform)
                                {
                                case Sequence.TweenMethodTransform.DOSizeDelta:
                                    FRVariableGUIUtility.DrawVariable(tweenSequence[s].targetVector2, this, false, editorSkin);
                                    break;

                                default:
                                    FRVariableGUIUtility.DrawVariable(tweenSequence[s].target, this, false, editorSkin);
                                    break;
                                }
                                break;

                            case Sequence.TweenObject.canvasGroup:
                                tweenSequence[s].tweenMethodCanvas = (Sequence.TweenMethodCanvas)EditorGUILayout.EnumPopup("", tweenSequence[s].tweenMethodCanvas, GUILayout.Width(100));
                                //tweenSequence[s].target.Value.x = EditorGUILayout.FloatField(tweenSequence[s].target.Value.x);
                                FRVariableGUIUtility.DrawVariable(tweenSequence[s].targetFloat, this, false, editorSkin);
                                break;
                            }
                        }


                        using (new GUILayout.HorizontalScope())
                        {
                            tweenSequence[s].easeType = (Ease)EditorGUILayout.EnumPopup("", tweenSequence[s].easeType, GUILayout.Width(100));
                            tweenSequence[s].duration = EditorGUILayout.FloatField(tweenSequence[s].duration);
                        }
                    }

                    if (tweenSequence[s].tweenState == Sequence.TweenState.append)
                    {
                        _totalDuration += tweenSequence[s].duration;
                    }
                    else
                    {
                        _totalDuration += tweenSequence[s].duration + tweenSequence[s].insertTime;
                    }
                }
            }
        }