コード例 #1
0
    public static void PerformMigration(int migrateStart, int migrateStop)
    {
        UpdateProgressBar(0f);

        UnityEngine.Debug.Log("WwiseUnity: Migrating incrementally to versions " + migrateStart + " up to " + migrateStop);

        AkPluginActivator.DeactivateAllPlugins();
        AkPluginActivator.Update();
        AkPluginActivator.ActivatePluginsForEditor();

        // Get the name of the currently opened scene.
        var currentScene        = AkSceneUtils.GetCurrentScene().Replace('/', '\\');
        var wwiseComponentTypes = GetWwiseComponentTypes();
        var sceneInfo           =
            new System.IO.DirectoryInfo(UnityEngine.Application.dataPath).GetFiles("*.unity", System.IO.SearchOption.AllDirectories);

        AkSceneUtils.CreateNewScene();
        AkUtilities.IsMigrating = true;

        AkWwiseProjectInfo.PopulateForMigration();
        AkWwiseWWUBuilder.UpdateWwiseObjectReferenceData();

        for (var i = 0; i < sceneInfo.Length; i++)
        {
            UpdateProgressBar((float)i / sceneInfo.Length);

            var scene = "Assets" + sceneInfo[i].FullName.Substring(UnityEngine.Application.dataPath.Length);
            UnityEngine.Debug.Log("WwiseUnity: Migrating scene " + scene);

            AkSceneUtils.OpenExistingScene(scene);
            MigrateCurrentScene(wwiseComponentTypes, migrateStart - 1, migrateStop - 1);

            AkWwiseWWUBuilder.PopulateWwiseObjectReferences();
            AkSceneUtils.SaveCurrentScene();
        }

        UpdateProgressBar(1.0f);

        AkSceneUtils.CreateNewScene();
        AkUtilities.IsMigrating = false;

        // Reopen the scene that was opened before the migration process started.
        AkSceneUtils.OpenExistingScene(currentScene);

        UnityEngine.Debug.Log("WwiseUnity: Removing lock for launcher.");

        // TODO: Moving one folder up is not nice at all. How to find the current project path?
        try
        {
            System.IO.File.Delete(UnityEngine.Application.dataPath + "/../.WwiseLauncherLockFile");
        }
        catch (System.Exception)
        {
            // Ignore if not present.
        }

        UnityEditor.EditorUtility.ClearProgressBar();
    }