Esempio n. 1
0
 void RenderEventNodeGUI(NodeEditor nodeEditor, XNode.Node node)
 {
     EditorGUILayout.BeginHorizontal();
     EditorGUILayout.BeginVertical();
     dENode = node as DialogEventNode;
     if (dENode != null)
     {
         if (dENode.dialogEvent == null)
         {
             return;
         }
         EditorGUILayout.BeginVertical(EditorStyles.helpBox);
         dENode.dialogEvent.type = (DialogObject.DialogEventType)EditorGUILayout.EnumPopup("Type", dENode.dialogEvent.type);
         EditorGUILayout.EndVertical();
         EditorGUILayout.BeginVertical(EditorStyles.helpBox);
         if (dENode.dialogEvent.type == DialogObject.DialogEventType.SetVar)
         {
             EditorGUILayout.LabelField("Var: " + dENode.dialogEvent.stringField);
             if (GUILayout.Button("Set Var"))
             {
                 ObjectPicker.GetObject(ObjectPicker.ObjectType.Variable, dENode.SetStringField);
                 // Debug.Log("Get/set vars");
             }
             dENode.dialogEvent.boolField = EditorGUILayout.Toggle("Value", dENode.dialogEvent.boolField);
         }
         EditorGUILayout.EndVertical();
     }
     EditorGUILayout.EndVertical();
     EditorGUILayout.EndHorizontal();
 }
Esempio n. 2
0
        //private EntityActionNode eaNode;
        //private EntityConditionNode ecNode;
        void RenderDialogNodeGUI(NodeEditor nodeEditor, XNode.Node node)
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.BeginVertical();
            dn = node as DialogNode;
            if (dn != null)
            {
                EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                if (dn.showDialogText = EditorGUILayout.Foldout(dn.showDialogText, "Dialog"))
                {
                    EditorGUILayout.LabelField("Dialog");
                    EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                    dn.dialog.text = EditorGUILayout.TextArea(dn.dialog.text, EditorStyles.wordWrappedLabel, GUILayout.MinHeight(60), GUILayout.MaxWidth(180));
                    EditorGUILayout.EndVertical();
                }
                EditorGUILayout.EndVertical();
                EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                if (dn.Options = EditorGUILayout.Foldout(dn.Options, "Options"))
                {
                    EditorGUILayout.LabelField("Talk ID");
                    dn.dialog.TalkID = EditorGUILayout.IntSlider(dn.dialog.TalkID, 0, 6);
                    dn.dialog.clip   = (AudioClip)EditorGUILayout.ObjectField("Audio", dn.dialog.clip, typeof(AudioClip), false);
                    if (dn.dialog.hasEvent = EditorGUILayout.Toggle("Event", dn.dialog.hasEvent))
                    {
                        dn.dialog.eventID = EditorGUILayout.IntField("Event ID", dn.dialog.eventID);
                    }
                    dn.dialog.isEntry = EditorGUILayout.Toggle("Is Entry", dn.dialog.isEntry);
                }
                EditorGUILayout.EndVertical();
                EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                if (dn.showDialogCondition = EditorGUILayout.Foldout(dn.showDialogCondition, "Conditions"))
                {
                    if (dn.dialog.conditions == null)
                    {
                        dn.dialog.conditions = new DialogObject.DialogCondition();
                    }
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.Space();
                    EditorGUILayout.BeginVertical();
                    EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                    dn.dialog.conditions.isOneTime = EditorGUILayout.Toggle("One Shot", dn.dialog.conditions.isOneTime);
                    if (dn.dialog.conditions.isOneTime && string.IsNullOrEmpty(dn.dialog.conditions.oneTimeID))
                    {
                        dn.dialog.conditions.oneTimeID = ToolKit.GetUniqueID();
                    }
                    EditorGUILayout.EndVertical();
                    EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                    if (dn.showDialogVar = EditorGUILayout.Foldout(dn.showDialogVar, "Global Var"))
                    {
                        EditorGUILayout.LabelField(dn.dialog.conditions.varID);
                        if (GUILayout.Button("Set Var"))
                        {
                            ObjectPicker.GetObject(ObjectPicker.ObjectType.Variable, dn.SetDialogVar);
                        }
                        dn.dialog.conditions.varState = EditorGUILayout.Toggle("State", dn.dialog.conditions.varState);
                    }
                    EditorGUILayout.EndVertical();

                    EditorGUILayout.EndVertical();
                    EditorGUILayout.EndHorizontal();
                }
                EditorGUILayout.EndVertical();

                EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
                if (GUILayout.Button("Add", EditorStyles.toolbarButton))
                {
                    dn.AddResponse();
                }
                if (GUILayout.Button("Remove", EditorStyles.toolbarButton))
                {
                    dn.RemoveResponse();
                }
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                {
                    int i = 0;
                    if (dn.selectedResponse > dn.dialog.responses.Length - 1)
                    {
                        dn.selectedResponse = -1;
                    }
                    foreach (DialogObject.DialogResponse response in dn.dialog.responses)
                    {
                        EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                        EditorGUILayout.BeginHorizontal();
                        string s = "";
                        if (!string.IsNullOrEmpty(response.response))
                        {
                            s = TruncateLongString(response.response, 16);
                        }
                        else
                        {
                            s = "Response " + i.ToString();
                        }
                        if (GUILayout.Button(s, EditorStyles.foldout))
                        {
                            if (dn.selectedResponse == i)
                            {
                                dn.selectedResponse = -1;
                            }
                            else
                            {
                                dn.selectedResponse = i;
                            }
                        }
                        nodeEditor.OnNodeGUI(i);
                        EditorGUILayout.EndHorizontal();
                        if (dn.selectedResponse == i)
                        {
                            if (dn.dialog.responses != null && dn.dialog.responses.Length > 0 && dn.selectedResponse >= 0)
                            {
                                EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                                dn.dialog.responses[dn.selectedResponse].response = EditorGUILayout.TextArea(dn.dialog.responses[dn.selectedResponse].response, EditorStyles.wordWrappedLabel, GUILayout.MinHeight(60), GUILayout.MaxWidth(180));
                                EditorGUILayout.EndVertical();
                                EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                                dn.responseOptions = EditorGUILayout.Foldout(dn.responseOptions, "Options");
                                if (dn.responseOptions)
                                {
                                    dn.conditionOptions = false;
                                    dn.dialog.responses[dn.selectedResponse].eventID = EditorGUILayout.IntField("Event", dn.dialog.responses[dn.selectedResponse].eventID);
                                }
                                EditorGUILayout.EndVertical();
                                EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                                dn.conditionOptions = EditorGUILayout.Foldout(dn.conditionOptions, "Conditions");
                                if (dn.conditionOptions)
                                {
                                    dn.responseOptions = false;
                                    if (dn.dialog.responses[dn.selectedResponse].conditions == null)
                                    {
                                        dn.dialog.responses[dn.selectedResponse].conditions = new DialogObject.DialogCondition();
                                    }
                                    EditorGUILayout.BeginHorizontal();
                                    EditorGUILayout.Space();
                                    EditorGUILayout.BeginVertical();
                                    EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                                    dn.dialog.responses[dn.selectedResponse].conditions.isOneTime = EditorGUILayout.Toggle("One Shot", dn.dialog.responses[dn.selectedResponse].conditions.isOneTime);
                                    if (dn.dialog.responses[dn.selectedResponse].conditions.isOneTime && string.IsNullOrEmpty(dn.dialog.responses[dn.selectedResponse].conditions.oneTimeID))
                                    {
                                        dn.dialog.responses[dn.selectedResponse].conditions.oneTimeID = ToolKit.GetUniqueID();
                                    }
                                    EditorGUILayout.EndVertical();
                                    EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                                    if (dn.showVar = EditorGUILayout.Foldout(dn.showVar, "Global Var"))
                                    {
                                        EditorGUILayout.LabelField(dn.dialog.responses[dn.selectedResponse].conditions.varID);
                                        if (GUILayout.Button("Set Var"))
                                        {
                                            //ObjectPicker.GetObject(ObjectPicker.ObjectType.Variable, dn.SetVar);
                                            Debug.Log("Get/set vars");
                                        }
                                        dn.dialog.responses[dn.selectedResponse].conditions.varState = EditorGUILayout.Toggle("State", dn.dialog.responses[dn.selectedResponse].conditions.varState);
                                    }
                                    EditorGUILayout.EndVertical();
                                    EditorGUILayout.EndVertical();
                                    EditorGUILayout.EndHorizontal();
                                }
                                EditorGUILayout.EndVertical();
                            }
                        }
                        i++;
                        EditorGUILayout.EndVertical();
                    }
                }
                EditorGUILayout.EndVertical();
                EditorGUILayout.EndVertical();
                EditorUtility.SetDirty(dn);
            }
            EditorGUILayout.EndVertical();
            EditorGUILayout.EndHorizontal();
        }
Esempio n. 3
0
 private void OnGUI()
 {
     EditorGUILayout.BeginHorizontal();
     EditorGUILayout.LabelField("Entity Object");
     dialogEntity = (GameObject)EditorGUILayout.ObjectField(dialogEntity, typeof(GameObject), true);
     EditorGUILayout.EndHorizontal();
     if (dialogEntity == null)
     {
         return;
     }
     if (dialogTrigger == null)
     {
         dialogTrigger = dialogEntity.GetComponent <DialogTrigger>();
     }
     if (dialogTrigger == null)
     {
         if (GUILayout.Button("Add Dialog Component"))
         {
             dialogTrigger = dialogEntity.AddComponent <DialogTrigger>();
         }
     }
     else
     {
         dialogTrigger.NPCName = EditorGUILayout.TextField("NPC Name", dialogTrigger.NPCName);
         #region Dialog Object
         if (dialogTrigger.dialogObject == null)
         {
             if (GUILayout.Button("Set Dialog"))
             {
                 ObjectPicker.GetObject(ObjectPicker.ObjectType.Dialog, SetDialog);
             }
         }
         else
         {
             EditorGUILayout.BeginHorizontal();
             EditorGUILayout.LabelField(dialogTrigger.dialogObject.name);
             if (GUILayout.Button("X"))
             {
                 dialogTrigger.dialogObject = null;
             }
             EditorGUILayout.EndHorizontal();
         }
         #endregion
         #region Audio Source
         EditorGUILayout.BeginHorizontal();
         EditorGUILayout.LabelField("Audio Source");
         dialogTrigger.source = (AudioSource)EditorGUILayout.ObjectField(dialogTrigger.source, typeof(AudioSource), true);
         if (dialogTrigger.source == null)
         {
             if (GUILayout.Button("Find Audio"))
             {
                 if (dialogTrigger.GetComponent <LipsyncController>())
                 {
                     dialogTrigger.source = dialogTrigger.GetComponent <LipsyncController>().mouthSource;
                 }
                 else
                 {
                     dialogTrigger.source = dialogTrigger.GetComponent <AudioSource>();
                 }
             }
         }
         EditorGUILayout.EndHorizontal();
         #endregion
         if (dialogTrigger.animator == null)
         {
             dialogTrigger.animator = dialogTrigger.GetComponent <Animator>();
         }
         if (requireVar = EditorGUILayout.Toggle("Require Variable", requireVar))
         {
             EditorGUILayout.BeginHorizontal();
             if (!string.IsNullOrEmpty(dialogTrigger.requiredVar))
             {
                 EditorGUILayout.LabelField(dialogTrigger.requiredVarName);
                 dialogTrigger.requiredValue = EditorGUILayout.Toggle(dialogTrigger.requiredValue);
                 if (GUILayout.Button("X"))
                 {
                     dialogTrigger.requiredVar     = "";
                     dialogTrigger.requiredVarName = "";
                 }
             }
             else
             {
                 if (GUILayout.Button("Set Var"))
                 {
                     ObjectPicker.GetObject(ObjectPicker.ObjectType.FullVar, SetRequiredVar);
                 }
             }
             EditorGUILayout.EndHorizontal();
         }
         EditorGUILayout.BeginHorizontal();
         EditorGUILayout.LabelField("Head Transfer");
         dialogTrigger.targetLookObj = (Transform)EditorGUILayout.ObjectField(dialogTrigger.targetLookObj, typeof(Transform), true);
         EditorGUILayout.EndHorizontal();
         dialogTrigger.RotateToTarget = EditorGUILayout.Toggle("Rotate On Interact", dialogTrigger.RotateToTarget);
         EditorGUILayout.BeginHorizontal();
         EditorGUILayout.LabelField("Interact Angle");
         dialogTrigger.interactAngle = EditorGUILayout.Slider(dialogTrigger.interactAngle, 15.0f, 180.0f);
         EditorGUILayout.EndHorizontal();
         EditorUtility.SetDirty(dialogTrigger);
         EditorGUILayout.Space();
         EditorGUILayout.Space();
         if (GUILayout.Button("Close"))
         {
             this.Close();
         }
     }
 }