public static void Init(string name, string projectDir, string outputAssemblyName, string outputDir) //, string buildConfiguration ) { Name = name; ProjectDir = projectDir; OutputAssemblyName = outputAssemblyName; OutputDir = outputDir; //BuildConfiguration = buildConfiguration; CSharpProjectFileUtility.FileWatcherInit(); }
public static void Shutdown() { ResourceUpdate.Shutdown(); //!!!!!еще раз. тут? ResourceManager.Shutdown(); VirtualFileWatcher.Shutdown(); CSharpProjectFileUtility.FileWatcherShutdown(); //!!!!! //PackageManager.Shutdown(); //ResourceTypes.Shutdown(); initialized = false; }
public override bool Creation(NewObjectCell.ObjectCreationContext context) { if (Window.IsFileCreation()) { context.disableFileCreation = true; GetCreateCSharpClassInfo(out var csharpRealFileName, out var csharpClassName, out var csharpClassNameWithoutNamespace); try { //main file { string name = Template.Name + ".scene"; var sourceFile = VirtualPathUtility.GetRealPathByVirtual(@"Base\Tools\NewResourceTemplates\" + name); //copy scene file var text = File.ReadAllText(sourceFile); if (CreateCSharpClass) { text = text.Replace(".component NeoAxis.Component_Scene", ".component " + csharpClassName); } File.WriteAllText(context.fileCreationRealFileName, text); //copy additional folder if exist var sourceFolderPath = sourceFile + "_Files"; if (Directory.Exists(sourceFolderPath)) { var destFolderPath = context.fileCreationRealFileName + "_Files"; IOUtility.CopyDirectory(sourceFolderPath, destFolderPath); } } //cs file if (CreateCSharpClass) { string code = @"using System; using System.Collections.Generic; using System.Text; using System.ComponentModel; using NeoAxis; namespace Project { public class {Name} : {Base} { } }"; code = code.Replace("{Name}", csharpClassNameWithoutNamespace); code = code.Replace("{Base}", Window.SelectedType.Name); File.WriteAllText(csharpRealFileName, code); } } catch (Exception e) { EditorMessageBox.ShowWarning(e.Message); //Log.Warning( e.Message ); return(false); } if (CreateCSharpClass) { //add to Project.csproj { var toAdd = new List <string>(); var fileName = Path.Combine("Assets", VirtualPathUtility.GetVirtualPathByReal(csharpRealFileName)); toAdd.Add(fileName); if (CSharpProjectFileUtility.UpdateProjectFile(toAdd, null, out var error)) { if (toAdd.Count > 1) { Log.Info(EditorLocalization.Translate("General", "Items have been added to the Project.csproj.")); } else { Log.Info(EditorLocalization.Translate("General", "The item has been added to the Project.csproj.")); } } else { EditorMessageBox.ShowWarning(error); //Log.Warning( error ); return(false); } } Window.DisableUnableToCreateReason = true; //restart application var text = EditorLocalization.Translate("General", "To apply changes need restart the editor. Restart?\r\n\r\nThe editor must be restarted to compile and enable a new created C# class."); if (EditorMessageBox.ShowQuestion(text, EMessageBoxButtons.YesNo) == EDialogResult.Yes) { EditorAPI.BeginRestartApplication(); } Window.DisableUnableToCreateReason = false; } } return(true); }
///////////////////////////////////////// public override bool GetProjectData(out List <string> csFiles, out List <string> references) { csFiles = new List <string>(CSharpProjectFileUtility.GetProjectFileCSFiles(false, true)); references = CSharpProjectFileUtility.GetProjectFileReferences(false); return(true); }