Beispiel #1
0
        public List <EditableParameter> ParameterList; // Serialized into the json string



        //--------------------------------------
        // Util
        //--------------------------------------

        public NodeEventHolder GetNodeData(int id)
        {
            // Create list if none
            if (NodeSerializedDataList == null)
            {
                NodeSerializedDataList = new List <NodeEventHolder>();
            }

            // Look through list to find by ID
            for (int i = 0; i < NodeSerializedDataList.Count; i++)
            {
                if (NodeSerializedDataList[i].NodeID == id)
                {
                    return(NodeSerializedDataList[i]);
                }
            }

            // If none exist, create a new GameObject
            Transform EventInfo = this.transform.Find(CHILD_NAME);

            if (EventInfo == null)
            {
                GameObject obj = new GameObject(CHILD_NAME);
                obj.transform.SetParent(this.transform);
            }
            EventInfo = this.transform.Find(CHILD_NAME);

            // Add a new Component for this node
            NodeEventHolder h = EventInfo.gameObject.AddComponent <NodeEventHolder>();

            h.NodeID = id;
            h.Event  = new UnityEngine.Events.UnityEvent();
            NodeSerializedDataList.Add(h);
            return(h);
        }
Beispiel #2
0
        private SpeechNode CreateSpeechNode(EditableSpeechNode editableNode)
        {
            SpeechNode speech = new SpeechNode();

            speech.Name = editableNode.Name;
            speech.Text = editableNode.Text;
            speech.AutomaticallyAdvance           = editableNode.AdvanceDialogueAutomatically;
            speech.AutoAdvanceShouldDisplayOption = editableNode.AutoAdvanceShouldDisplayOption;
            speech.TimeUntilAdvance = editableNode.TimeUntilAdvance;
            speech.TMPFont          = editableNode.TMPFont;
            speech.Icon             = editableNode.Icon;
            speech.Audio            = editableNode.Audio;
            speech.Volume           = editableNode.Volume;

            CopyParamActions(editableNode, speech);

            NodeEventHolder holder = this.GetNodeData(editableNode.ID);

            if (holder != null)
            {
                speech.Event = holder.Event;
            }

            return(speech);
        }
Beispiel #3
0
        void OnEnable()
        {
            s           = new GUIStyle();
            s.alignment = TextAnchor.MiddleCenter;
            s.wordWrap  = true;

            n = (base.target as NodeEventHolder);
        }
Beispiel #4
0
        private OptionNode CreateOptionNode(EditableOptionNode editableNode)
        {
            OptionNode option = new OptionNode();

            option.Text    = editableNode.Text;
            option.TMPFont = editableNode.TMPFont;

            CopyParamActions(editableNode, option);

            NodeEventHolder holder = this.GetNodeData(editableNode.ID);

            if (holder != null)
            {
                option.Event = holder.Event;
            }

            return(option);
        }
        private void DrawPanel()
        {
            panelRect = new Rect(position.width - panelWidth, TOOLBAR_HEIGHT, panelWidth, position.height - TOOLBAR_HEIGHT);
            if (panelStyle.normal.background == null)
            {
                InitGUIStyles();
            }
            GUILayout.BeginArea(panelRect, panelStyle);
            GUILayout.BeginVertical();
            panelVerticalScroll = GUILayout.BeginScrollView(panelVerticalScroll);

            GUI.SetNextControlName("CONTROL_TITLE");

            GUILayout.Space(10);

            if (CurrentlySelectedNode != null)
            {
                bool differentNodeSelected = (m_cachedSelectedNode != CurrentlySelectedNode);
                m_cachedSelectedNode = CurrentlySelectedNode;
                if (differentNodeSelected)
                {
                    GUI.FocusControl(CONTROL_NAME);
                }

                if (CurrentlySelectedNode is UISpeechNode)
                {
                    EditableSpeechNode node = (CurrentlySelectedNode.Info as EditableSpeechNode);
                    GUILayout.Label("[" + node.ID + "] NPC Dialogue Node.", panelTitleStyle);
                    EditorGUILayout.Space();

                    GUILayout.Label("Character Name", EditorStyles.boldLabel);
                    GUI.SetNextControlName(CONTROL_NAME);
                    node.Name = GUILayout.TextField(node.Name);
                    EditorGUILayout.Space();

                    GUILayout.Label("Dialogue", EditorStyles.boldLabel);
                    node.Text = GUILayout.TextArea(node.Text);
                    EditorGUILayout.Space();

                    // Advance
                    if (node.Speech != null || node.Options == null || node.Options.Count == 0)
                    {
                        GUILayout.Label("Auto-Advance options", EditorStyles.boldLabel);
                        node.AdvanceDialogueAutomatically = EditorGUILayout.Toggle("Automatically Advance", node.AdvanceDialogueAutomatically);
                        if (node.AdvanceDialogueAutomatically)
                        {
                            node.AutoAdvanceShouldDisplayOption = EditorGUILayout.Toggle("Display continue option", node.AutoAdvanceShouldDisplayOption);
                            node.TimeUntilAdvance = EditorGUILayout.FloatField("Dialogue Time", node.TimeUntilAdvance);
                            if (node.TimeUntilAdvance < 0f)
                            {
                                node.TimeUntilAdvance = 0f;
                            }
                        }
                        EditorGUILayout.Space();
                    }

                    GUILayout.Label("Icon", EditorStyles.boldLabel);
                    node.Icon = (Sprite)EditorGUILayout.ObjectField(node.Icon, typeof(Sprite), false, GUILayout.ExpandWidth(true));
                    EditorGUILayout.Space();

                    GUILayout.Label("Audio Options", EditorStyles.boldLabel);
                    GUILayout.Label("Audio");
                    node.Audio = (AudioClip)EditorGUILayout.ObjectField(node.Audio, typeof(AudioClip), false);

                    GUILayout.Label("Audio Volume");
                    node.Volume = EditorGUILayout.Slider(node.Volume, 0, 1);
                    EditorGUILayout.Space();

                    GUILayout.Label("TMP Font", EditorStyles.boldLabel);
                    node.TMPFont = (TMPro.TMP_FontAsset)EditorGUILayout.ObjectField(node.TMPFont, typeof(TMPro.TMP_FontAsset), false);
                    EditorGUILayout.Space();

                    // Events
                    {
                        NodeEventHolder NodeEvent = CurrentAsset.GetNodeData(node.ID);
                        if (differentNodeSelected)
                        {
                            CurrentAsset.Event = NodeEvent.Event;
                        }

                        if (NodeEvent != null && NodeEvent.Event != null)
                        {
                            // Load the object and property of the node
                            SerializedObject   o = new SerializedObject(NodeEvent);
                            SerializedProperty p = o.FindProperty("Event");

                            // Load the dummy event
                            SerializedObject   o2 = new SerializedObject(CurrentAsset);
                            SerializedProperty p2 = o2.FindProperty("Event");

                            // Draw dummy event
                            GUILayout.Label("Events:", EditorStyles.boldLabel);
                            EditorGUILayout.PropertyField(p2);

                            // Apply changes to dummy
                            o2.ApplyModifiedProperties();

                            // Copy dummy changes onto the nodes event
                            p = p2;
                            o.ApplyModifiedProperties();
                        }
                    }
                }
                else if (CurrentlySelectedNode is UIOptionNode)
                {
                    EditableOptionNode node = (CurrentlySelectedNode.Info as EditableOptionNode);
                    GUILayout.Label("[" + node.ID + "] Option Node.", panelTitleStyle);

                    GUILayout.Label("Option text:", EditorStyles.boldLabel);
                    node.Text = GUILayout.TextArea(node.Text);

                    GUILayout.Label("TMP Font", EditorStyles.boldLabel);
                    node.TMPFont = (TMPro.TMP_FontAsset)EditorGUILayout.ObjectField(node.TMPFont, typeof(TMPro.TMP_FontAsset), false);
                }
            }
            else
            {
                GUILayout.Label("Conversation options.", panelTitleStyle);

                GUILayout.Label("Default name:", EditorStyles.boldLabel);
                CurrentAsset.DefaultName = EditorGUILayout.TextField(CurrentAsset.DefaultName);

                GUILayout.Label("Default Icon:", EditorStyles.boldLabel);
                CurrentAsset.DefaultSprite = (Sprite)EditorGUILayout.ObjectField(CurrentAsset.DefaultSprite, typeof(Sprite), false);

                GUILayout.Label("Default font:", EditorStyles.boldLabel);
                CurrentAsset.DefaultFont = (TMPro.TMP_FontAsset)EditorGUILayout.ObjectField(CurrentAsset.DefaultFont, typeof(TMPro.TMP_FontAsset), false);
            }

            GUILayout.EndScrollView();
            GUILayout.EndVertical();
            GUILayout.EndArea();
        }
 void OnEnable()
 {
     n = (base.target as NodeEventHolder);
 }