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); }
public static SerializedProperty FindEntry(SerializedObject serialConversation, int ID) { SerializedProperty dialogueEntry = null; if (IsConversation(serialConversation)) { dialogueEntry = SerializedArrayUtility.FindPropertyByValue(serialConversation.FindProperty("Entries"), "ID", ID); } return(dialogueEntry); }
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(); } }
public override SerializedProperty ContentsAsProperty(SerializedObject conversation) { return(SerializedArrayUtility.FindPropertyByValue(conversation.FindProperty("Entries"), "ID", entryID)); }
public override SerializedProperty ContentsAsProperty(SerializedObject conversation) { SerializedProperty entry = SerializedArrayUtility.FindPropertyByValue(conversation.FindProperty("Entries"), "ID", entryID); return(entry.FindPropertyRelative("Responses").GetArrayElementAtIndex(index)); }