Created
September 26, 2016 09:29
-
-
Save iwashihead/502315fbfc913fc158a5a11150da4a5b to your computer and use it in GitHub Desktop.
【Unity】Project内の全シーンに処理を実行する ref: http://qiita.com/iwashihead/items/07bc7a916d73b6d4e879
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEditor; | |
using UnityEditor.SceneManagement; | |
using UnityEngine.SceneManagement; | |
using System; | |
using System.IO; | |
using System.Linq; | |
/// <summary> | |
/// シーン操作クラス | |
/// </summary> | |
public class SceneOperation | |
{ | |
/// <summary> | |
/// Project内の全てのシーンに対して処理を実行します | |
/// </summary> | |
public static void OperationAllScene(Action<Scene> action) | |
{ | |
var cnt = 0; | |
var scenePathList = AssetDatabase.GetAllAssetPaths().Where(_ => Path.GetExtension(_) == ".unity").ToList(); | |
foreach (var path in scenePathList) | |
{ | |
var scene = EditorSceneManager.OpenScene(path); | |
EditorUtility.DisplayProgressBar("全Scene操作", scene.name + "シーンの操作をしています", (float) cnt / scenePathList.Count); | |
// TODO ここに処理を追加. | |
if (action != null) action(scene); | |
EditorSceneManager.SaveScene(scene); | |
EditorSceneManager.CloseScene(scene, true); | |
cnt++; | |
} | |
EditorUtility.ClearProgressBar(); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment