Ejemplo n.º 1
0
        public override void OnGUI()
        {
            base.OnGUI();

            CanvasGUI.BeginGroup(Position, GUI.skin.box, actor.Tint, HasControl);

            if (Locked)
            {
                GUI.Label(new Rect(5, 5, 240, 20), name);
            }
            else
            {
                string nodeName = name;

                if (CanvasGUI.TextField(new Rect(5, 5, 240, 20), ref nodeName))
                {
                    name = DialogueEditorGUI.Cache.Nodes.ItemNames[DialogueEditorGUI.Cache.Nodes.ItemNames.IndexOf(name)] = nodeName;
                }
            }

            if (CanvasGUI.Button(new Rect(Position.size.x - 50, 5, 20, 20), new GUIContent("L"), GUI.skin.button))
            {
                Locked = !Locked;
            }

            if (CanvasGUI.Button(new Rect(Position.size.x - 25, 5, 20, 20), new GUIContent("X"), GUI.skin.button))
            {
                Delete();
            }
            textArea = CanvasGUI.TextArea(new Rect(5, 30, 290, 65), textArea);

            CanvasGUI.EndGroup();
        }
Ejemplo n.º 2
0
            public override void OnGUI()
            {
                Event current   = Event.current;
                Rect  tolerance = new Rect(position);

                tolerance.xMin -= 20;
                tolerance.xMax += 20;
                tolerance.yMin -= 20;
                tolerance.yMax += 20;

                bool hasFocus = tolerance.Contains(current.mousePosition);

                CanvasGUI.BeginGroup(position, GUI.skin.box, hasFocus);

                string nodeName = obj.name;

                if (CanvasGUI.TextField(new Rect(5, 5, 240, 20), ref nodeName))
                {
                    obj.name = DialogueEditorGUI.Cache.Actors.ItemNames[DialogueEditorGUI.Cache.Actors.ItemNames.IndexOf(obj.name)] = nodeName;
                }
                obj.Tint = UnityEditor.EditorGUI.ColorField(new Rect(5, 30, 140, 20), obj.Tint);

                CanvasGUI.EndGroup();

                if (current.type == EventType.MouseUp && !hasFocus)
                {
                    close = true;
                }

                if (!obj || close)
                {
                    UpdateOverlays(obj);
                }
            }
        void ToolBar()
        {
            CanvasGUI.BeginGroup(CanvasGUI.ToolBarRect, GUI.skin.box, cache.States.curSpace == EventSpace.Toolbar);

            GUI.Label(new Rect(5, 5, CanvasGUI.ToolBarRect.width - 10, 20), new GUIContent(cache.CanvasName + (cache.AutoLoaded ? " (Last Session)" : "")));

            if (CanvasGUI.Button(new Rect(5, 30, CanvasGUI.ToolBarRect.width - 10, 20), "Save"))
            {
                cache = (cache.IsFileSaved && !cache.AutoLoaded) ? EditorCache.SaveCache(cache.SavePath ?? AssetDatabase.GetAssetPath(cache), cache) : SaveCanvas();
            }

            if (CanvasGUI.Button(new Rect(5, 55, CanvasGUI.ToolBarRect.width - 10, 20), "Save As"))
            {
                SaveCanvas();
            }

            if (CanvasGUI.Button(new Rect(5, 80, CanvasGUI.ToolBarRect.width - 10, 20), "Load"))
            {
                LoadCanvas();
            }

            if (CanvasGUI.Button(new Rect(5, 105, CanvasGUI.ToolBarRect.width - 10, 20), "New Canvas"))
            {
                cache = EditorCache.NewCache();
            }

            if (CanvasGUI.Button(new Rect(5, 130, CanvasGUI.ToolBarRect.width - 10, 20), "Settings"))
            {
                Setting();
            }

            CanvasGUI.EndGroup();
        }
        public static void OnGUI(EditorStates states)
        {
            States = states;
            EditorState curState = states.curState;

            CanvasGUI.BeginGroup(new Rect(curState.panDelta, curState.canvasSize), (states.curSpace | EventSpace.CanvasSpace) == EventSpace.CanvasSpace);

            for (int i = 0; i < Cache.Nodes.Count; i++)
            {
                Cache.Nodes.Get(i).DrawConnection();
            }

            if (curState.connectionIndex > -1)
            {
                BaseNodule startNodule = curState.selectedObject as BaseNodule;

                if (curState.connectionIndex > startNodule.Nodules.Count - 1)
                {
                    InputHandlers.OnSelectConnection(states);
                }
                else
                {
                    CanvasGUI.DrawConnection(startNodule, startNodule.Nodules.Get(curState.connectionIndex), Color.red);
                }
            }
            Cache.Nodes.OnGUI();

            CanvasGUI.EndGroup();
            CanvasGUI.BeginGroup(CanvasGUI.OptionRect, GUI.skin.box, states.curSpace == EventSpace.Actor);

            switch (tab)
            {
            case OptionTab.actor:
                Cache.Actors.OnGUI();
                break;

            case OptionTab.condition:
                Cache.Conditions.OnGUI();
                break;
            }

            if (CanvasGUI.Button(new Rect(5, 5, 70, 20), "Conditions"))
            {
                tab = OptionTab.condition;
            }
            else if (CanvasGUI.Button(new Rect(80, 5, 50, 20), "Actors"))
            {
                tab = OptionTab.actor;
            }

            CanvasGUI.EndGroup();
        }
Ejemplo n.º 5
0
        public override void OnGUI()
        {
            base.OnGUI();

            CanvasGUI.BeginGroup(Position, GUI.skin.box, actor.Tint, HasControl);

            if (Locked)
            {
                GUI.Label(new Rect(5, 5, 240, 20), name);
                GUI.Label(new Rect(5, 30, 240, 20), actor.name);
            }
            else
            {
                EditorCache cache    = DialogueEditorGUI.Cache;
                string      nodeName = name;

                if (CanvasGUI.TextField(new Rect(5, 5, 240, 20), ref nodeName))
                {
                    name = cache.Nodes.ItemNames[cache.Nodes.ItemNames.IndexOf(name)] = nodeName;
                }

                ActorDatabase actors = cache.Actors;
                actor = actors.Get(CanvasGUI.DropDownMenu(new Rect(5, 30, 240, 20),
                                                          position, actors.GetIndex(actor), actors.ItemNames.ToArray()));
            }

            if (CanvasGUI.Button(new Rect(Position.size.x - 50, 5, 20, 20), new GUIContent("L"), GUI.skin.button))
            {
                Locked = !Locked;
            }

            if (CanvasGUI.Button(new Rect(Position.size.x - 25, 5, 20, 20), new GUIContent("X"), GUI.skin.button))
            {
                Delete();
            }
            textArea = CanvasGUI.TextArea(new Rect(5, 55, 290, 115), textArea);

            if (CanvasGUI.Button(new Rect(5, 175, 290, 20), new GUIContent("Add Dialogue Option"), GUI.skin.button))
            {
                options.Add(OptionNode.Create(options.NextItemName("Option"), this));
            }

            CanvasGUI.EndGroup();

            options.OnGUI();
        }
Ejemplo n.º 6
0
            public override void OnGUI()
            {
                Event current   = Event.current;
                Rect  tolerance = new Rect(position);

                tolerance.xMin -= 20;
                tolerance.xMax += 20;
                tolerance.yMin -= 20;
                tolerance.yMax += 20;

                bool hasFocus = tolerance.Contains(current.mousePosition);

                CanvasGUI.BeginGroup(position, GUI.skin.box, hasFocus);

                ConditionDatabase conditions = DialogueEditorGUI.Cache.Conditions;

                obj.Condition = conditions.Get(CanvasGUI.DropDownMenu(new Rect(5, 5, position.width - 10, 20), position,
                                                                      conditions.GetIndex(obj.Condition), conditions.ItemNames.ToArray()));

                for (int i = 0; i < obj.ConditionValues.Count; i++)
                {
                    var val = obj.ConditionValues[i];

                    CanvasGUI.TextLabel(new Rect(30, 30 + 25 * 1, 20, 20), val.userParam.ToString());

                    string[] names = Enum.GetNames(typeof(EqualityState));
                    val.equality = (EqualityState)Enum.Parse(typeof(EqualityState),
                                                             names[CanvasGUI.DropDownMenu(new Rect(5, 30 + 25, 100, 20), (int)val.equality, names)]);
                }

                CanvasGUI.EndGroup();

                if (current.type == EventType.MouseUp && !hasFocus)
                {
                    close = true;
                }

                if (!obj || close)
                {
                    UpdateOverlays(obj);
                }
            }
Ejemplo n.º 7
0
        protected override void OnGUI()
        {
            for (int i = 0; i < groupsToDraw.Count; i++)
            {
                ItemGroup itemGroup = groupsToDraw[i];
                Rect      tolerance = new Rect(itemGroup.position);
                tolerance.xMin -= 20;
                tolerance.yMin -= 20;
                tolerance.xMax += 20;
                tolerance.yMax += 20;
                bool hasFocus = tolerance.Contains(Event.current.mousePosition);

                CanvasGUI.BeginGroup(itemGroup.position, GUI.skin.box, hasFocus);

                foreach (MenuItem item in itemGroup)
                {
                    if (item.content.text.Equals("Saparator"))
                    {
                        GUI.Label(item.position, "----------");
                    }
                    else if (item.position.Contains(Event.current.mousePosition))
                    {
                        if (Event.current.type == EventType.MouseUp && Event.current.button == 0)
                        {
                            if (item.Group)
                            {
                                groupsToDraw.Add(item.subItems);
                            }
                            else
                            {
                                item.Execute();
                                close = true;
                            }
                            Event.current.Use();
                        }

                        if (item.Group && groupsToDraw.Exists(j => j == item.subItems))
                        {
                            item.subItems.forceFocus = true;
                        }
                        CanvasGUI.Box(item.position, item.content);
                    }
                    else
                    {
                        if (item.Group && groupsToDraw.Exists(j => j == item.subItems))
                        {
                            item.subItems.forceFocus = false;
                        }
                        GUI.Label(item.position, item.content);
                    }

                    if (item.Group)
                    {
                        GUI.Label(new Rect(item.position.position + new Vector2(item.position.size.x - GroupIconSize, 0),
                                           new Vector2(GroupIconSize, minHeight)), ">");
                    }
                }

                CanvasGUI.EndGroup();

                if (!hasFocus && !itemGroup.forceFocus)
                {
                    if (i != 0)
                    {
                        groupsToDraw.Remove(itemGroup);
                    }
                    else if (Event.current.type == EventType.MouseUp)
                    {
                        close = true;
                    }
                }
            }

            if (groupsToDraw.Count == 0 || close)
            {
                OnClose();
            }
            DialogueEditorGUI.OnRepaint();
        }