public override void DrawCustomInspector()
        {
            GUILayout.Label("Databox Object:");
            databoxObject = (DataboxObject)EditorGUILayout.ObjectField(databoxObject, typeof(DataboxObject), false);

            FRVariableGUIUtility.DrawVariable("Table ID:", tableID, this, false, editorSkin);
            FRVariableGUIUtility.DrawVariable("Entry ID:", entryID, this, false, editorSkin);

            GUILayout.Label("Register to:");
            databoxObjectToRegister = (DataboxObject)EditorGUILayout.ObjectField(databoxObjectToRegister, typeof(DataboxObject), false);
            FRVariableGUIUtility.DrawVariable("New entry ID:", newEntryID, this, false, editorSkin);
        }
Esempio n. 2
0
        public override void DrawCustomInspector()
        {
            GUILayout.Label("Run mode:");
            runMode = (RunMode)EditorGUILayout.EnumPopup(runMode);

            switch (runMode)
            {
            case RunMode.Sequential:
                currentFlowIcon = flowIconSequential;

                EditorGUILayout.HelpBox(sequentialHelpText, MessageType.Info);

                break;

            case RunMode.Parallel:
                currentFlowIcon = flowIconParallel;

                EditorGUILayout.HelpBox(parallelHelpText, MessageType.Info);

                break;

            case RunMode.Select:
                currentFlowIcon = flowIconSelect;

                EditorGUILayout.HelpBox(selectHelpText, MessageType.Info);

                GUILayout.Label("Selected output index");

                selectedOutput.Value = EditorGUILayout.IntSlider(selectedOutput.Value, 0, outputNodes.Count - 1);
                FRVariableGUIUtility.DrawVariable(selectedOutput, this, false, editorSkin);

                for (int i = 0; i < outputNodes.Count; i++)
                {
                    if (selectedOutput.Value == i)
                    {
                        outputNodes[i].id = ">>";
                    }
                    else
                    {
                        outputNodes[i].id = "";
                    }
                }

                break;

            case RunMode.Random:
                currentFlowIcon = flowIconRandom;
                EditorGUILayout.HelpBox(randomHelpText, MessageType.Info);
                break;

            case RunMode.RandomWeightBased:
                currentFlowIcon = flowIconRandomWB;
                EditorGUILayout.HelpBox(randomWeightBasedHelpText, MessageType.Info);

                lastRunMode = runMode;
                // assign weight values to output ids
                for (int i = 0; i < outputNodes.Count; i++)
                {
                    outputNodes[i].id = weights[i].Value.ToString();
                }

                break;
            }

            // reset output ids
            if (lastRunMode != runMode && (runMode != RunMode.RandomWeightBased || runMode != RunMode.Select))
            {
                lastRunMode = runMode;
                for (int i = 0; i < outputNodes.Count; i++)
                {
                    outputNodes[i].id = "";
                }
            }

            GUILayout.Space(10);
            EditorHelpers.DrawUILine();

            if (GUILayout.Button("Add Output"))
            {
                AddOutput("");
                weights.Add(new FRFloat());
            }


            for (int i = 0; i < outputNodes.Count; i++)
            {
                if (selectedOutput.Value == i && runMode == RunMode.Select)
                {
                    GUI.color = selectedOutputColor;
                }
                else
                {
                    GUI.color = Color.white;
                }

                using (new GUILayout.HorizontalScope("Box"))
                {
                    GUILayout.Label("output: " + i.ToString());

                    if (runMode == RunMode.RandomWeightBased)
                    {
                        weights[i].Value = EditorGUILayout.Slider(weights[i].Value, 0f, 1f);
                        GUILayout.FlexibleSpace();
                        FRVariableGUIUtility.DrawVariable(weights[i], this, false, editorSkin);
                    }

                    if (i > 1)
                    {
                        if (GUILayout.Button("x", GUILayout.Width(20)))
                        {
                            RemoveOutput(i);
                            weights.RemoveAt(i);
                        }
                    }
                }

                GUI.color = Color.white;
            }
        }
Esempio n. 3
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);
                            }
                        }
                    }
                }
            }
        }
Esempio n. 4
0
        public override void DrawCustomInspector()
        {
            using (new GUILayout.VerticalScope())
            {
                using (new GUILayout.HorizontalScope())
                {
                    if (!string.IsNullOrEmpty(objectIcon))
                    {
                        GUILayout.Label(EditorGUIUtility.IconContent(objectIcon), GUILayout.Width(40), GUILayout.Height(40));
                    }

                    DropAreaGUI();


                    if (GUILayout.Button(EditorGUIUtility.IconContent("ViewToolZoom"), GUILayout.Width(32), GUILayout.Height(32)))
                    {
                        Object _obj = AssetDatabase.LoadAssetAtPath(fullPath, typeof(Object));
                        Selection.activeObject = _obj;
                    }
                }
            }

            using (new GUILayout.VerticalScope())
            {
                GUILayout.Label("Asset: " + resourcePath, "boldLabel");
            }

            GUILayout.Label("Store to:");
            FRVariableGUIUtility.DrawVariable(result, this, false, editorSkin);

            if (obj != lastObj)
            {
                lastObj = obj;

                string _path = AssetDatabase.GetAssetPath(obj);


                fullPath = _path;

                _path = Path.Combine(Path.GetDirectoryName(_path), Path.GetFileNameWithoutExtension(_path));

                var _fullPathWithoutExtension = _path;

                var _ind = _path.IndexOf("Resources");
                resourcePath = _path.Substring(_ind + 10, _fullPathWithoutExtension.Length - (_ind + 10));

                objType = obj.GetType().Name.ToString();

                switch (objType)
                {
                case "GameObject":
                    objectIcon = "d_Prefab Icon";
                    break;

                case "Texture2D":
                    objectIcon = "Texture2D Icon";
                    break;

                case "AudioClip":
                    objectIcon = "AudioClip Icon";
                    break;

                case "MonoScript":
                    objectIcon = "cs Script Icon";
                    break;

                case "TextAsset":
                    objectIcon = "TextAsset Icon";
                    break;

                case "Material":
                    objectIcon = "Material Icon";
                    break;

                case "AudioMixerController":
                    objectIcon = "AudioMixerGroup Icon";
                    break;

                case "Shader":
                    objectIcon = "Shader Icon";
                    break;

                case "AnimationClip":
                    objectIcon = "AnimationClip Icon";
                    break;

                default:
                    objectIcon = "GameObject Icon";
                    break;
                }
            }
        }
Esempio n. 5
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;
                    }
                }
            }
        }