public override bool Creation(NewObjectCell.ObjectCreationContext context) { var newObject2 = (Component_LensFlares)context.newObject; if (CreateDefaultFlares) { newObject2.CreateDefaultFlares(); } return(base.Creation(context)); }
public override bool Creation(NewObjectCell.ObjectCreationContext context) { var method = (Component_Method)context.newObject; if (FlowGraph) { method.NewObjectCreateFlowGraph(); } return(base.Creation(context)); }
public override bool Creation(NewObjectCell.ObjectCreationContext context) { var newObject2 = (Component_RenderingEffect_CodeGenerated)context.newObject; if (ShaderGraph) { newObject2.NewObjectCreateShaderGraph(); } return(base.Creation(context)); }
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); }