Beispiel #1
0
        private void OnDrawEditableElement(Rect rect, int index, bool isActive, bool isFocused)
        {
            if (!(0 <= index && index < questReorderableList.serializedProperty.arraySize))
            {
                return;
            }
            var buttonWidth      = 48f;
            var questRect        = new Rect(rect.x, rect.y + 1, rect.width - buttonWidth - 2, EditorGUIUtility.singleLineHeight);
            var buttonRect       = new Rect(rect.x + rect.width - buttonWidth, rect.y + 1, buttonWidth, EditorGUIUtility.singleLineHeight);
            var questProperty    = questReorderableList.serializedProperty.GetArrayElementAtIndex(index);
            var isQuestAssigned  = questProperty.objectReferenceValue != null;
            var buttonGUIContent = isQuestAssigned ? new GUIContent("Edit", "Edit in Quest Editor window.") : new GUIContent("New", "Create new quest in this slot.");

            EditorGUI.BeginChangeCheck();
            EditorGUI.PropertyField(questRect, questProperty, GUIContent.none, false);
            if (EditorGUI.EndChangeCheck())
            {
                SetQuestInEditorWindow(index);
            }
            if (GUI.Button(buttonRect, buttonGUIContent))
            {
                if (!isQuestAssigned)
                {
                    questProperty.objectReferenceValue = QuestEditorAssetUtility.CreateNewQuestAssetFromDialog();
                }
                QuestEditorWindow.ShowWindow();
                SetQuestInEditorWindow(index);
                questReorderableList.index = index;
            }
        }
        private void SaveGeneratedQuestAsAsset()
        {
            var filename = EditorUtility.SaveFilePanelInProject("Save Quest As", "New Quest", "asset", "Save quest as");

            if (string.IsNullOrEmpty(filename))
            {
                return;
            }
            QuestEditorAssetUtility.SaveQuestAsAsset(m_quest, filename, true);
        }
 private void CheckQuestFileVersion()
 {
     if (m_quest != null && m_quest.isAsset && m_quest.fileVersion < CurrentFileVersion)
     {
         if (m_quest.fileVersion == 0)
         {
             // A bug in 1.0.0 - 1.0.2 orphaned subassets when deleting a node.
             // This method scrubs them from the quest asset:
             QuestEditorAssetUtility.DeleteUnusedSubassets(m_quest);
         }
         UpdateSelectedQuestSerializedObject();
         selectedQuestSerializedObject.FindProperty("m_fileVersion").intValue = CurrentFileVersion;
         ApplyModifiedPropertiesFromSelectedQuestSerializedObject();
     }
 }
 // A bug in 1.0.0 - 1.0.2 orphaned subassets when deleting a node.
 // This method scrubs them from the quest asset:
 private void DeleteUnusedSubassets()
 {
     QuestEditorAssetUtility.DeleteUnusedSubassets(m_quest);
 }