Пример #1
0
        private void CreateUnlimitedRecord()
        {
            if (!recordName.IsValid())
            {
                UnityEditorUtility.DisplayTip("Record name cannot be null!");
            }

            MakeCreateRecordMenu(RecordNumberType.Unlimited);
        }
Пример #2
0
        private void CreateScriptInSelectDirectory()
        {
            var defaultDirectory = outputDirectory ?? Application.dataPath;
            var targetDirectory  = EditorUtility.OpenFolderPanel
                                       ("Please select script output directory",
                                       defaultDirectory, null);

            if (!Directory.Exists(targetDirectory))
            {
                UnityEditorUtility.DisplayTip("No directory selected!");
                return;
            }
            outputDirectory = targetDirectory.EnsureDirectoryFormat();
            CreateScript();
        }
Пример #3
0
 private bool CheckCreateInfoError()
 {
     if (!outputDirectory.IsValid())
     {
         UnityEditorUtility.DisplayTip("No script cretion" +
                                       "directory selected!");
         return(true);
     }
     if (!Directory.Exists(outputDirectory))
     {
         UnityEditorUtility.DisplayTip(
             "The target directory is not a valid directory!");
         return(true);
     }
     if (csharpCreateInfos == null || csharpCreateInfos.Count == 0)
     {
         UnityEditorUtility.DisplayTip(
             "Create information cannot be empty");
         return(true);
     }
     foreach (var createInfo in csharpCreateInfos)
     {
         if (!createInfo.ScriptName.IsValid())
         {
             UnityEditorUtility.DisplayTip(
                 "Script Name cannot be empty");
             return(true);
         }
         if (!globalNameSpace.IsValid())
         {
             UnityEditorUtility.DisplayTip(
                 "Global namespace cannot be empty");
             return(true);
         }
         var finalPath = GetScriptOutPath(createInfo, outputDirectory);
         if (File.Exists(finalPath))
         {
             UnityEditorUtility.DisplayTip(
                 "Script already exists on the target path!");
             return(true);
         }
     }
     return(false);
 }
Пример #4
0
        private void CreateScript()
        {
            if (CheckCreateInfoError())
            {
                return;
            }
            var appender = new CsharpScriptAppender();

            foreach (var createInfo in csharpCreateInfos)
            {
                appender.Clean();
                var scriptPath     = GetScriptOutPath(createInfo, outputDirectory);
                var scripteContent = GetScriptContent(appender, createInfo);
                FileUtility.WriteAllText(scriptPath, scripteContent);
            }
            SaveDeveloperInfo();
            AssetDatabase.Refresh();
            UnityEditorUtility.DisplayTip("Script is created");
        }