示例#1
0
        public static Quest CreateNewQuestAssetFromDialog()
        {
            var filePath = EditorUtility.SaveFilePanel("Save Quest As", s_lastDirectory, string.Empty, "asset");

            if (string.IsNullOrEmpty(filePath))
            {
                return(null);
            }
            s_lastDirectory = System.IO.Path.GetDirectoryName(filePath);
            var questWrapperType = QuestEditorUtility.GetWrapperType(typeof(Quest));

            if (questWrapperType == null)
            {
                Debug.LogError("Quest Machine: Internal error. Can't access Quest type!");
                return(null);
            }
            var quest = ScriptableObjectUtility.CreateScriptableObject(questWrapperType) as Quest;

            if (quest == null)
            {
                Debug.LogError("Quest Machine: Internal error. Can't create Quest object!");
                return(null);
            }
            var filename = System.IO.Path.GetFileNameWithoutExtension(filePath);

            quest.id.value    = filename.Replace(" ", string.Empty);
            quest.title.value = filename;
            return(SaveQuestAsAsset(quest, filePath, false));
        }
        private void OnClickNewUrgencyFunction(object data)
        {
            var type = data as System.Type;

            if (type == null)
            {
                return;
            }
            var assetInfoList = AssetInfoLists.GetList(AssetType);

            if (assetInfoList == null)
            {
                return;
            }
            var wrapperType = QuestEditorUtility.GetWrapperType(type);

            if (wrapperType != null)
            {
                type = wrapperType;
            }
            var newAsset = AssetUtility.CreateAsset(type, AssetType.Name, true);

            assetInfoList.Add(new AssetInfo(newAsset));
        }