protected internal override bool ConnectObjectToDialogueEntry(DialogueEditorWindow window, int targetID)
        {
            // Get Conversation object from window
            SerializedObject conversation = window.SerializedConversation;
            bool             success      = false;

            if (conversation != null)
            {
                conversation.Update();
                SerializedProperty entries = conversation.FindProperty("Entries");
                // HACK use SerializedConversationUtility to find entries
                // Find own entry and target entry properties in conversation
                SerializedProperty serializedEntry  = SerializedArrayUtility.FindPropertyByValue(entries, "ID", entryID);
                SerializedProperty serializedTarget = SerializedArrayUtility.FindPropertyByValue(entries, "ID", targetID);
                SerializedProperty transitions      = serializedEntry.FindPropertyRelative("transitions.transitions");
                int oldSize = transitions.arraySize;
                transitions.InsertArrayElementAtIndex(oldSize);
                SerializedProperty newTransition = transitions.GetArrayElementAtIndex(oldSize);
                newTransition.FindPropertyRelative("condition").objectReferenceValue = null;
                newTransition.FindPropertyRelative("transition.TargetID").intValue   = targetID;

                conversation.ApplyModifiedProperties();
                success = true;
            }
            return(success);
        }
Beispiel #2
0
        protected override void ProcessContextMenu(DialogueEditorWindow window)
        {
            // Make context menu for right click
            GenericMenu menu = new GenericMenu();

            menu.AddItem(new GUIContent("Add Transition"), false, OnClickNewTransition);
            menu.AddItem(new GUIContent("Delete"), false, () => OnClickDelete(window));
            menu.ShowAsContext();
        }
 protected override void OnClickAsTarget(DialogueEditorWindow window, EditorConnector connector)
 {
     // DialogueEntry can be connected to, so ask connector's parent to try it and if so make connection
     if (connector.Parent.ConnectObjectToDialogueEntry(window, entryID))
     {
         connector.Parent.Connections.Add(connector);
         connector.Target = this;
     }
 }
        protected override void ProcessContextMenu(DialogueEditorWindow window)
        {
            GenericMenu menu = new GenericMenu();

            menu.AddItem(new GUIContent("Add Transition"), false, OnClickNewTransition);
            menu.AddItem(new GUIContent("Add Response"), false, () => OnClickAddResponse(window));
            menu.AddSeparator("");
            menu.AddItem(new GUIContent("Delete"), false, () => OnClickDelete(window));
            menu.ShowAsContext();
        }
Beispiel #5
0
        protected override void OnClickDelete(DialogueEditorWindow window)
        {
            SerializedObject conversation = window.SerializedConversation;

            if (conversation != null)
            {
                // Delete response from conversation
                conversation.Update();
                SerializedProperty entry = SerializedConversationUtility.FindEntry(conversation, entryID);
                entry.FindPropertyRelative("Responses").DeleteArrayElementAtIndex(index);
                conversation.ApplyModifiedProperties();
            }
        }
        protected void OnClickAddResponse(DialogueEditorWindow window)
        {
            SerializedObject conversation = window.SerializedConversation;

            if (conversation != null)
            {
                conversation.Update();
                // Get serialized property for this node
                SerializedProperty serialEntry = SerializedConversationUtility.FindEntry(conversation, entryID);
                if (serialEntry != null)
                {
                    SerializedDialogueEntryUtility.AddResponse(serialEntry);
                }
                conversation.ApplyModifiedProperties();
            }
        }
        protected override void OnClickDelete(DialogueEditorWindow window)
        {
            SerializedObject conversation = window.SerializedConversation;

            if (conversation != null)
            {
                conversation.Update();
                // Find index in conversation
                SerializedProperty entries = conversation.FindProperty("Entries");
                int index = SerializedArrayUtility.FindIndexByValue(entries, "ID", entryID);
                if (index >= 0)
                {
                    entries.DeleteArrayElementAtIndex(index);
                    // HACK move this out to SerializedConversationUtility
                }
                conversation.ApplyModifiedProperties();
            }
        }
Beispiel #8
0
        protected internal override bool ConnectObjectToDialogueEntry(DialogueEditorWindow window, int targetID)
        {
            SerializedObject conversation = window.SerializedConversation;
            bool             success      = false;

            if (conversation != null)
            {
                conversation.Update();
                SerializedProperty serializedEntry    = SerializedConversationUtility.FindEntry(conversation, entryID);
                SerializedProperty serializedResponse = serializedEntry.FindPropertyRelative("Responses").GetArrayElementAtIndex(index);
                SerializedProperty transitions        = serializedResponse.FindPropertyRelative("transitions.transitions");
                //TODO write some SerializedTransitionListUtility with an insert new transition function
                int oldSize = transitions.arraySize;
                transitions.InsertArrayElementAtIndex(oldSize);
                SerializedProperty newTransition = transitions.GetArrayElementAtIndex(oldSize);
                newTransition.FindPropertyRelative("condition").objectReferenceValue = null;
                newTransition.FindPropertyRelative("transition.TargetID").intValue   = targetID;
                conversation.ApplyModifiedProperties();
                success = true;
            }
            return(success);
        }
        public void ProcessEvents(Event e, DialogueEditorWindow window)
        {
            switch (e.type)
            {
            case EventType.MouseDown:
                if (rect.Contains(e.mousePosition))
                {
                    switch (e.button)
                    {
                    case 0:        //LMB
                        if (window.SelectedConnector == null)
                        {
                            // If not making connection, select node
                            GUI.changed = true;
                            isDragged   = true;
                            window.SelectNode(this);
                            e.Use();
                        }
                        else
                        {
                            // If making connection, connect to this
                            OnClickAsTarget(window, window.SelectedConnector);
                            window.OnFinishMakeTransition();
                            e.Use();
                        }
                        break;

                    case 1:         //RMB
                        // Create dropdown menu
                        ProcessContextMenu(window);
                        e.Use();
                        break;

                    default:
                        break;
                    }
                }
                break;

            case EventType.MouseUp:
                switch (e.button)
                {
                case 0:         //LMB up, stop dragging
                    isDragged = false;
                    break;

                default:
                    break;
                }
                break;

            case EventType.MouseDrag:
                if (e.button == 0 && isDragged)     // LMB
                {
                    // Drag the event
                    Drag(e.delta);
                    e.Use();
                    GUI.changed = true;
                }
                break;

            default:
                break;
            }
            // Returns whether event consumed by node
        }
 protected internal abstract bool ConnectObjectToDialogueEntry(DialogueEditorWindow window, int targetID);
 protected abstract void OnClickAsTarget(DialogueEditorWindow window, EditorConnector connector);
 protected abstract void OnClickDelete(DialogueEditorWindow window);
 protected abstract void ProcessContextMenu(DialogueEditorWindow window);
Beispiel #14
0
 public void ProcessEvents(Event e, DialogueEditorWindow window)
 {
 }
Beispiel #15
0
        static void Init()
        {
            DialogueEditorWindow window = EditorWindow.GetWindow <DialogueEditorWindow>();

            window.Show();
        }
Beispiel #16
0
 protected override void OnClickAsTarget(DialogueEditorWindow window, EditorConnector connector)
 {
     // Response can't be made a target as it belongs to its dialogue entry
 }