(string outputPath, object arg)
| 39 | |
| 40 | /// <inheritdoc /> |
| 41 | public override void Create(string outputPath, object arg) |
| 42 | { |
| 43 | // Load template |
| 44 | GetTemplatePath(out var templatePath); |
| 45 | var scriptTemplate = File.ReadAllText(templatePath); |
| 46 | |
| 47 | // Find the module that this script is being added (based on the path) |
| 48 | var scriptNamespace = Editor.Instance.GameProject.Name; |
| 49 | var project = TryGetProjectAtFolder(outputPath, out var moduleName); |
| 50 | if (project != null) |
| 51 | { |
| 52 | scriptNamespace = moduleName.Length != 0 ? moduleName : project.Name; |
| 53 | } |
| 54 | scriptNamespace = scriptNamespace.Replace(" ", ""); |
| 55 | |
| 56 | // Format |
| 57 | var gameSettings = GameSettings.Load(); |
| 58 | var scriptName = ScriptItem.CreateScriptName(outputPath); |
| 59 | var copyrightComment = string.IsNullOrEmpty(gameSettings.CopyrightNotice) ? string.Empty : string.Format("// {0}{1}{1}", gameSettings.CopyrightNotice, Environment.NewLine); |
| 60 | scriptTemplate = scriptTemplate.Replace("%copyright%", copyrightComment); |
| 61 | scriptTemplate = scriptTemplate.Replace("%class%", scriptName); |
| 62 | scriptTemplate = scriptTemplate.Replace("%namespace%", scriptNamespace); |
| 63 | |
| 64 | // Save |
| 65 | File.WriteAllText(outputPath, scriptTemplate, Encoding.UTF8); |
| 66 | } |
| 67 | |
| 68 | /// <inheritdoc /> |
| 69 | public override string FileExtension => "cs"; |
nothing calls this directly
no test coverage detected