예제 #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);
                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();
        }
예제 #2
0
        static void AddCallBack(object callBackObj)
        {
            EditorStates states = callBackObj as EditorStates;

            if (states == null)
            {
                throw new UnityException();
            }
            EditorState state = states.curState;

            if (states.info.Contains("Node"))
            {
                switch (states.curSpace)
                {
                case EventSpace.Node:
                    if (states.info == "OptionNode")
                    {
                        if (state.selectedObject is MainNode)
                        {
                            MainNode main = state.selectedObject as MainNode;
                            main.Options.Add(OptionNode.Create(main.Options.NextItemName("Option"), main));
                        }
                        else
                        {
                            goto default;
                        }
                    }
                    else if (states.info == "MainNode")
                    {
                        goto default;
                    }
                    else
                    {
                        Debug.LogError("Cannot recognise name of 'Node'. Add More Error here");
                        return;
                    }
                    break;

                default:
                    EditorCache cache = DialogueEditorGUI.Cache;
                    cache.Nodes.Add(DialogueNode.Create(states.info,
                                                        cache.Nodes.NextItemName(states.info),
                                                        CanvasGUI.CanvasToScreenPosition(state, states.mousePos),
                                                        cache.Actors.DefaultActor));
                    break;
                }
            }
            else if (states.info.Contains("Nodule"))
            {
                BaseNode node = (states.curSpace == EventSpace.Node) ? state.selectedObject as BaseNode :
                                (states.curSpace == EventSpace.Nodule) ? (state.selectedObject as BaseNodule).MainNode :
                                null;

                if (node)
                {
                    node.Nodules.Add(BaseNodule.Create(states.info, node.Nodules.NextItemName(states.info), node));
                }
            }
            else
            {
                throw new UnityException();
            }
        }