private void OnWizardCreate() { if (!AssetDatabase.IsValidFolder(prefabs_folder)) { AssetDatabase.CreateFolder("Assets", "Prefabs"); } if (!AssetDatabase.IsValidFolder(ruins_folder)) { AssetDatabase.CreateFolder("Assets/Prefabs", "Ruins"); } string ruinPath = "Assets/Prefabs/Ruins/" + nickname + ".prefab"; // Warning dialog if file exists. Debug.Log(AssetDatabase.FindAssets(ruinPath)); if (AssetDatabase.LoadAssetAtPath(ruinPath, typeof(GameObject)) && !EditorUtility.DisplayDialog("Replace Existing File?", "Should " + ruinPath + " be replaced?", "replace", "cancel")) { return; } RuinGenerator gen = new RuinGenerator { num_rounds = rounds, num_elite = elites }; GameObject obj = gen.GenerateRuin(ShowGenerationProgressBar).Instantiate(); PrefabUtility.CreatePrefab(ruinPath, obj); DestroyImmediate(obj); EditorUtility.ClearProgressBar(); }
private void OnWizardCreate() { if (!AssetDatabase.IsValidFolder(prefabs_folder)) { AssetDatabase.CreateFolder("Assets", "Prefabs"); } if (!AssetDatabase.IsValidFolder(ruins_folder)) { AssetDatabase.CreateFolder("Assets/Prefabs", "Ruins"); } string ruinPath = "Assets/Prefabs/Ruins/" + nickname + ".prefab"; // Warning dialog if file exists. Debug.Log(AssetDatabase.FindAssets(ruinPath)); if (AssetDatabase.LoadAssetAtPath(ruinPath, typeof(GameObject)) && !EditorUtility.DisplayDialog("Replace Existing File?", "Should " + ruinPath + " be replaced?", "replace", "cancel")) { return; } RuinGenerator gen = new RuinGenerator() { num_rounds = rounds, num_elite = elites, pop_size = pop_size, on_status_update = OnStatusUpdate }; Blueprint blueprint = gen.GenerateRuin(); blueprint.SaveAsPrefab("Assets/Prefabs/Ruins", nickname); EditorUtility.ClearProgressBar(); }