Ejemplo n.º 1
0
        public void GenerateScript()
        {
            var savePath = string.Format("{1}{0}{2}.cs", CSVLoaderWindow.Seperator(), generateData.scriptFilePath, generateData.scriptSetting.scriptName);

            /* 当前为加载模式,如果文件存在就不需要创建 */
            if (!generateData.generateScriptFlag && File.Exists(savePath))
            {
                return;
            }
            /* 检测相同脚本 */
            if (generateData.CheckHaveSameScript(generateData.scriptSetting.scriptFullname, true))
            {
                generateData.SetState(BlockState.ERROR);
                return;
            }
            if (File.Exists(savePath))
            {
                CSVLoaderWindow.window.ShowNotification(new GUIContent($"文件\"{generateData.scriptSetting.scriptName}\"已存在"));
                generateData.SetState(BlockState.ERROR);
                return;
            }
            StreamWriter sw = File.CreateText(savePath);

            sw.Write(scriptContent);
            sw.Flush();
            sw.Close();
        }
Ejemplo n.º 2
0
        public void GenerateAsset()
        {
            /* 当文件存在时 */
            var assetPath = $"{Helper.DataPathWithoutAssets()}{CSVLoaderWindow.Seperator()}{generateData.resourceFilePath}";

            if (File.Exists(assetPath))
            {
                assetObject = AssetDatabase.LoadAssetAtPath(generateData.resourceFilePath, typeof(ScriptableObject)) as ScriptableObject;
            }
            else
            {
                assetObject = ScriptableObject.CreateInstance(generateData.scriptSetting.scriptAssetFullName);
                AssetDatabase.CreateAsset(assetObject, generateData.resourceFilePath);
            }
        }