/// <summary> /// シーン作成ダイアログ表示 /// </summary> public static void DisplayBuildDialog(string directory) { // ダイアログを開く string fullpath = EditorUtility.SaveFilePanel("シーン作成先のフォルダ選択", directory, "", ""); if (string.IsNullOrEmpty(fullpath)) { return; } string path = "Assets" + fullpath.Substring(Application.dataPath.Length); if (string.IsNullOrEmpty(path)) { return; } if (AssetChecker.Exists(path)) { return; } // シーン作成 bool success; var data = TryBuildScene(path, out success); if (success) { UnityCallback.SetActionOnCompiled(new TemporaryFileData(data)); } }
/// <summary> /// 複数シーン作成ダイアログ表示 /// </summary> public static void DisplayBuildDialogMulti(string[] sceneNames) { // スクリプトの依存関係取得 var scriptDependency = DataLoader.LoadScriptDependency(); // ダイアログを開く var fullpath = EditorUtility.SaveFolderPanel("シーン作成先のフォルダ選択", "Assets", ""); string path = "Assets" + fullpath.Substring(Application.dataPath.Length); if (string.IsNullOrEmpty(path)) { return; } var corrctedSceneNames = sceneNames.Select(name => NameCorrector.CorrectNameIfInvalid(name)).ToArray(); if (corrctedSceneNames.Length == 0) { return; } // 作成 var dataList = new List <TemporaryFileData.Data>(); float progressDelta = 1f / sceneNames.Length; float progress = 0f; foreach (var sceneName in corrctedSceneNames) { // プログレスバー progress += progressDelta; EditorUtility.DisplayProgressBar(string.Format("シーン\"{0}\"の作成中...", sceneName), "", progress); if (string.IsNullOrEmpty(sceneName)) { continue; } // if (AssetChecker.Exists(Path.Combine(path, sceneName))) { continue; } bool success; var data = TryBuildScene(Path.Combine(path, sceneName), out success); if (success) { dataList.Add(data); } } // コンパイル終了時の処理 設定 EditorUtility.DisplayProgressBar("マネージャオブジェクトの作成中...", "", 1f); var file = new TemporaryFileData(dataList.ToArray()); UnityCallback.SetActionOnCompiled(file); }