private static void CreateScreen_AfterCompilation() { var waitForCompilation = EditorPrefs.GetBool("Temp.EditorWaitCompilation.CreateFeatureComplex"); if (waitForCompilation == true) { EditorPrefs.DeleteKey("Temp.EditorWaitCompilation.CreateFeatureComplex"); var dir = EditorPrefs.GetString("Temp.EditorWaitCompilation.CreateFeatureComplex.Dir"); var assetName = EditorPrefs.GetString("Temp.EditorWaitCompilation.CreateFeatureComplex.Name"); var assetNameOrig = EditorPrefs.GetString("Temp.EditorWaitCompilation.CreateFeatureComplex.Name.Orig"); var assetPath = EditorPrefs.GetString("Temp.EditorWaitCompilation.CreateFeatureComplex.ScriptPath"); var newAssetPath = EditorPrefs.GetString("Temp.EditorWaitCompilation.CreateFeatureComplex.NewScriptPath"); if (assetNameOrig.EndsWith("Screen") == false) { var content = System.IO.File.ReadAllText(assetPath); content = content.Replace(@"/*#SCRIPTNAME_POST#*/", "Screen"); System.IO.File.WriteAllText(assetPath, content); } else { var content = System.IO.File.ReadAllText(assetPath); content = content.Replace(@"/*#SCRIPTNAME_POST#*/", ""); System.IO.File.WriteAllText(assetPath, content); } AssetDatabase.MoveAsset(assetPath, newAssetPath); AssetDatabase.ImportAsset(newAssetPath, ImportAssetOptions.ForceSynchronousImport); var guid = AssetDatabase.AssetPathToGUID(newAssetPath); var defs = new Dictionary <string, string>() { { "GUID", guid }, }; ScriptTemplates.CreateEmptyDirectory(dir, "Screens"); ScriptTemplates.CreateEmptyDirectory(dir, "Components"); ScriptTemplates.CreateEmptyDirectory(dir, "Layouts"); var asset = AssetDatabase.LoadAssetAtPath <TextAsset>(newAssetPath); AssignIcon(asset, new GUIContent(Resources.Load <Texture>("EditorAssets/Scripts/window_icon"))); ScriptTemplates.Create(dir + "/Screens", assetName + "Screen.prefab", "61-ScreenAsset", allowRename: false, customDefines: defs); } }
internal static void Create(string fileName, string templateName, System.Collections.Generic.Dictionary <string, string> customDefines = null, bool allowRename = true, System.Action <Object> onCreated = null) { var obj = Selection.activeObject; var path = AssetDatabase.GetAssetPath(obj); if (System.IO.File.Exists(path) == true) { path = System.IO.Path.GetDirectoryName(path); } if (string.IsNullOrEmpty(path) == true) { path = "Assets/"; } ScriptTemplates.Create(path, fileName, templateName, customDefines, allowRename, onCreated); }
public static void CreateScreen() { ScriptTemplates.Create("New Screen.cs", "01-ScreenTemplate", onCreated: (asset) => { var path = ScriptTemplates.GetDirectoryFromAsset(asset); var assetName = asset.name; if (assetName.EndsWith("Screen") == true) { assetName = assetName.Replace("Screen", string.Empty); } ScriptTemplates.CreateEmptyDirectory(path, assetName); var dir = path + "/" + assetName; var newAssetPath = dir + "/" + assetName + "Screen.cs"; EditorPrefs.SetBool("Temp.EditorWaitCompilation.CreateFeatureComplex", true); EditorPrefs.SetString("Temp.EditorWaitCompilation.CreateFeatureComplex.Dir", dir); EditorPrefs.SetString("Temp.EditorWaitCompilation.CreateFeatureComplex.Name", assetName); EditorPrefs.SetString("Temp.EditorWaitCompilation.CreateFeatureComplex.Name.Orig", asset.name); EditorPrefs.SetString("Temp.EditorWaitCompilation.CreateFeatureComplex.ScriptPath", AssetDatabase.GetAssetPath(asset)); EditorPrefs.SetString("Temp.EditorWaitCompilation.CreateFeatureComplex.NewScriptPath", newAssetPath); }); }
public static void CreateView() { ScriptTemplates.Create("New View.cs", "60-NoViewTemplate"); }
public static void CreateView() { ScriptTemplates.Create("New View.cs", "62-ViewParticlesTemplate"); }
public static void CreateView() { ScriptTemplates.Create("New View.cs", "63-ViewGraphicsTemplate"); }
public static void CreateView() { ScriptTemplates.Create("New View.cs", "61-ViewMonoBehaviourTemplate"); }