Example #1
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            SerializedProperty conversationProp        = property.FindPropertyRelative("conversation");
            SerializedProperty jumpToSpecificEntryProp = property.FindPropertyRelative("jumpToSpecificEntry");
            SerializedProperty entryIDProp             = property.FindPropertyRelative("entryID");

            Rect singleFieldRect = new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight);

            EditorGUI.PropertyField(singleFieldRect, conversationProp);

            singleFieldRect.y += EditorGUIUtility.singleLineHeight;
            EditorGUI.PropertyField(singleFieldRect, jumpToSpecificEntryProp);

            if (jumpToSpecificEntryProp.boolValue)
            {
                singleFieldRect.y += EditorGUIUtility.singleLineHeight;
                if (entryPicker == null)
                {
                    entryPicker = new DialogueEntryPicker(conversationProp.stringValue);
                }
                if (entryPicker.isValid)
                {
                    entryIDProp.intValue = entryPicker.Draw(singleFieldRect, "Entry ID", entryIDProp.intValue);
                }
                else
                {
                    EditorGUI.PropertyField(singleFieldRect, entryIDProp);
                }
            }
        }
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            SerializedProperty conversationProp        = property.FindPropertyRelative(nameof(StartConversationBehaviour.conversation));
            SerializedProperty jumpToSpecificEntryProp = property.FindPropertyRelative(nameof(StartConversationBehaviour.jumpToSpecificEntry));
            SerializedProperty entryIDProp             = property.FindPropertyRelative(nameof(StartConversationBehaviour.entryID));

            Rect singleFieldRect = new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight);

            if (GUI.Button(singleFieldRect, "Update Duration"))
            {
                UpdateLength(conversationProp.stringValue, jumpToSpecificEntryProp.boolValue, entryIDProp.intValue);
            }

            singleFieldRect.y += EditorGUIUtility.singleLineHeight;
            EditorGUI.PropertyField(singleFieldRect, conversationProp);

            singleFieldRect.y += EditorGUIUtility.singleLineHeight;
            EditorGUI.PropertyField(singleFieldRect, jumpToSpecificEntryProp);

            if (jumpToSpecificEntryProp.boolValue)
            {
                singleFieldRect.y += EditorGUIUtility.singleLineHeight;
                if (entryPicker == null)
                {
                    entryPicker = new DialogueEntryPicker(conversationProp.stringValue);
                }
                if (entryPicker.isValid)
                {
                    entryIDProp.intValue = entryPicker.Draw(singleFieldRect, "Entry ID", entryIDProp.intValue);
                }
                else
                {
                    EditorGUI.PropertyField(singleFieldRect, entryIDProp);
                }
            }
        }
        protected virtual void DrawConversationAction()
        {
            foldouts.conversationFoldout = EditorWindowTools.EditorGUILayoutFoldout("Start Conversation", "Start a conversation.", foldouts.conversationFoldout, false);
            if (foldouts.conversationFoldout)
            {
                try
                {
                    var conversationProperty = serializedObject.FindProperty("conversation");
                    var hadConversation      = !string.IsNullOrEmpty(conversationProperty.stringValue);
                    EditorWindowTools.EditorGUILayoutBeginGroup();
                    EditorGUILayout.PropertyField(conversationProperty, true);
                    if (string.IsNullOrEmpty(conversationProperty.stringValue))
                    {
                        if (hadConversation)
                        {
                            showConversationAction = false;
                        }
                    }
                    else
                    {
                        EditorGUILayout.PropertyField(serializedObject.FindProperty("conversationActor"), true);
                        EditorGUILayout.PropertyField(serializedObject.FindProperty("conversationConversant"), true);

                        var entryIDProperty = serializedObject.FindProperty("startConversationEntryID");
                        var specifyEntryID  = EditorGUILayout.Toggle(new GUIContent("Specify Starting Entry", "Start conversation at a specific entry ID."), (entryIDProperty.intValue != -1));
                        if (specifyEntryID)
                        {
                            if (entryPicker == null)
                            {
                                entryPicker = new DialogueEntryPicker(conversationProperty.stringValue);
                            }
                            if (entryPicker.isValid)
                            {
                                entryIDProperty.intValue = Mathf.Max(0, entryPicker.DoLayout("Entry ID", entryIDProperty.intValue));
                            }
                            else
                            {
                                entryIDProperty.intValue = Mathf.Max(0, EditorGUILayout.IntField(new GUIContent("Entry ID", "Start at this entry ID."), entryIDProperty.intValue));
                            }
                        }
                        else
                        {
                            entryIDProperty.intValue = -1;
                        }

                        EditorGUILayout.PropertyField(serializedObject.FindProperty("exclusive"), true);
                        EditorGUILayout.PropertyField(serializedObject.FindProperty("skipIfNoValidEntries"), true);
                        EditorGUILayout.PropertyField(serializedObject.FindProperty("stopConversationOnTriggerExit"), true);
                        EditorGUILayout.PropertyField(serializedObject.FindProperty("stopConversationIfTooFar"), true);
                        if (serializedObject.FindProperty("stopConversationIfTooFar").boolValue)
                        {
                            EditorGUILayout.PropertyField(serializedObject.FindProperty("maxConversationDistance"), true);
                            EditorGUILayout.PropertyField(serializedObject.FindProperty("monitorConversationDistanceFrequency"), true);
                        }
                        EditorGUILayout.PropertyField(serializedObject.FindProperty("showCursorDuringConversation"), true);
                        EditorGUILayout.PropertyField(serializedObject.FindProperty("pauseGameDuringConversation"), true);
                    }
                }
                finally
                {
                    EditorWindowTools.EditorGUILayoutEndGroup();
                }
            }
        }