Пример #1
0
    private static void MigrateObject(UnityEngine.Object obj)
    {
        if (obj == null)
        {
            UnityEngine.Debug.LogWarning("WwiseUnity: Missing script! Please consider resolving the missing scripts before migrating your Unity project. Any WwiseType on this object will NOT be migrated!");
            return;
        }

        var migratable = obj as AK.Wwise.IMigratable;

        if (migratable == null && !AkUtilities.IsMigrationRequired(AkUtilities.MigrationStep.WwiseTypes_v2018_1_6))
        {
            return;
        }

        var hasChanged       = false;
        var serializedObject = new UnityEditor.SerializedObject(obj);

        if (migratable != null)
        {
            hasChanged = migratable.Migrate(serializedObject);
        }
        else
        {
            hasChanged = AK.Wwise.TypeMigration.SearchAndProcessWwiseTypes(serializedObject.GetIterator());
        }

        if (hasChanged)
        {
            serializedObject.ApplyModifiedPropertiesWithoutUndo();
        }
    }
Пример #2
0
#pragma warning restore 0414 // private field assigned but not used.

#if UNITY_EDITOR
    bool AK.Wwise.IMigratable.Migrate(UnityEditor.SerializedObject obj)
    {
        if (!AkUtilities.IsMigrationRequired(AkUtilities.MigrationStep.WwiseTypes_v2018_1_6))
        {
            return(false);
        }

        return(AK.Wwise.TypeMigration.ProcessSingleGuidType(obj.FindProperty("data.WwiseObjectReference"), WwiseObjectType.Soundbank,
                                                            obj.FindProperty("valueGuidInternal"), obj.FindProperty("bankNameInternal")));
    }
Пример #3
0
    bool AK.Wwise.IMigratable.Migrate(UnityEditor.SerializedObject obj)
    {
        if (!AkUtilities.IsMigrationRequired(AkUtilities.MigrationStep.NewScriptableObjectFolder_v2019_2_0))
        {
            return(false);
        }

        UnityEditor.Undo.AddComponent <AkRoomAwareObject>(gameObject);

        return(true);
    }
Пример #4
0
#pragma warning restore 0414 // private field assigned but not used.

#if UNITY_EDITOR
    public virtual bool Migrate(UnityEditor.SerializedObject obj)
    {
        var hasMigrated = false;

        if (AkUtilities.IsMigrationRequired(AkUtilities.MigrationStep.WwiseTypes_v2018_1_6))
        {
            hasMigrated = AK.Wwise.TypeMigration.ProcessSingleGuidType(obj.FindProperty("data.WwiseObjectReference"), WwiseObjectType.Event,
                                                                       obj.FindProperty("valueGuidInternal"), obj.FindProperty("eventIdInternal"));
        }

        if (!AkUtilities.IsMigrationRequired(AkUtilities.MigrationStep.AkEventCallback_v2018_1_6))
        {
            return(hasMigrated);
        }

        var oldCallbackDataProperty = obj.FindProperty("m_callbackDataInternal");
        var oldCallbackData         = oldCallbackDataProperty.objectReferenceValue as AkEventCallbackData;

        if (!oldCallbackData)
        {
            return(hasMigrated);
        }

        var count = oldCallbackData.callbackFlags.Count;

        if (count != oldCallbackData.callbackFunc.Count || count != oldCallbackData.callbackGameObj.Count)
        {
            UnityEngine.Debug.LogWarning("WwiseUnity: Inconsistent callback data!");
            return(hasMigrated);
        }

        var newCallbackData = obj.FindProperty("Callbacks");

        newCallbackData.arraySize = count;
        obj.FindProperty("useCallbacks").boolValue = true;

        for (var i = 0; i < count; ++i)
        {
            var data = newCallbackData.GetArrayElementAtIndex(i);
            data.FindPropertyRelative("GameObject").objectReferenceValue = oldCallbackData.callbackGameObj[i];
            data.FindPropertyRelative("FunctionName").stringValue        = oldCallbackData.callbackFunc[i];
            data.FindPropertyRelative("Flags.value").intValue            = oldCallbackData.callbackFlags[i];
            UnityEngine.Debug.Log("WwiseUnity: Migrated Callback for function \"" + oldCallbackData.callbackFunc[i] + "\" on <" + oldCallbackData.callbackGameObj[i] + "> with flags <" + (AkCallbackType)oldCallbackData.callbackFlags[i] + ">.");
        }

        return(true);
    }
#pragma warning restore 0414 // private field assigned but not used.

#if UNITY_EDITOR
    bool AK.Wwise.IMigratable.Migrate(UnityEditor.SerializedObject obj)
    {
        if (!AkUtilities.IsMigrationRequired(AkUtilities.MigrationStep.NewScriptableObjectFolder_v2019_2_0))
        {
            return(false);
        }

        var hasChanged = false;

        var numAcousticTextures = 1;
        var meshProperty        = obj.FindProperty("Mesh");

        if (meshProperty != null)
        {
            var meshFilter = GetComponent <UnityEngine.MeshFilter>();
            if (meshFilter)
            {
                var sharedMesh = meshFilter.sharedMesh;
                if (sharedMesh)
                {
                    hasChanged = true;
                    meshProperty.objectReferenceValue = sharedMesh;
                    numAcousticTextures = sharedMesh.subMeshCount;
                }
            }
        }

        var oldwwiseObjRefProperty = obj.FindProperty("AcousticTextureInternal.WwiseObjectReference");

        if (oldwwiseObjRefProperty != null)
        {
            var objectReferenceValue = oldwwiseObjRefProperty.objectReferenceValue;
            if (objectReferenceValue != null)
            {
                hasChanged = true;
                var acousticTextures = obj.FindProperty("AcousticTextures");
                acousticTextures.arraySize = numAcousticTextures;
                for (int i = 0; i < numAcousticTextures; ++i)
                {
                    acousticTextures.GetArrayElementAtIndex(i).FindPropertyRelative("WwiseObjectReference").objectReferenceValue = objectReferenceValue;
                }
            }
        }

        return(hasChanged);
    }
#pragma warning restore 0414 // private field assigned but not used.

#if UNITY_EDITOR
    public override bool Migrate(UnityEditor.SerializedObject obj)
    {
        var hasMigrated = base.Migrate(obj);

        if (!AkUtilities.IsMigrationRequired(AkUtilities.MigrationStep.AkAmbient_v2019_1_0))
        {
            return(hasMigrated);
        }

        var multiPositionTypeLabelProperty = obj.FindProperty("multiPositionTypeLabel");

        if (multiPositionTypeLabelProperty == null)
        {
            return(hasMigrated);
        }

        if (multiPositionTypeLabelProperty.intValue != (int)MultiPositionTypeLabel.Large_Mode)
        {
            return(hasMigrated);
        }

        var multiPositionArrayProperty = obj.FindProperty("multiPositionArray");

        if (multiPositionArrayProperty == null)
        {
            return(hasMigrated);
        }

        if (multiPositionArrayProperty.arraySize == 0)
        {
            return(hasMigrated);
        }

        var largeModePositionsProperty = obj.FindProperty("LargeModePositions");

        if (largeModePositionsProperty == null)
        {
            return(hasMigrated);
        }

        largeModePositionsProperty.arraySize = multiPositionArrayProperty.arraySize;

        for (int point = 0; point < multiPositionArrayProperty.arraySize; ++point)
        {
            var elementProperty = multiPositionArrayProperty.GetArrayElementAtIndex(point);

            var largeModePositionElementProperty = largeModePositionsProperty.GetArrayElementAtIndex(point);
            if (largeModePositionElementProperty != null)
            {
                UnityEngine.GameObject newPoint = new UnityEngine.GameObject("AkAmbientPoint" + point.ToString());
                newPoint.AddComponent <AkAmbientLargeModePositioner>();
                newPoint.transform.SetParent(transform);
                newPoint.transform.position = transform.TransformPoint(elementProperty.vector3Value);

                largeModePositionElementProperty.objectReferenceValue = newPoint.GetComponent <AkAmbientLargeModePositioner>();
            }
        }

        multiPositionArrayProperty.arraySize = 0;
        return(true);
    }
Пример #7
0
    public static void PerformMigration(int migrateStart)
    {
        UpdateProgressBar(0);

        UnityEngine.Debug.Log("WwiseUnity: Migrating from Unity Integration Version " + migrateStart + " to " + AkUtilities.MigrationStopIndex);

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

        // Get the name of the currently opened scene.
        var activeScene     = UnityEngine.SceneManagement.SceneManager.GetActiveScene();
        var loadedScenePath = activeScene.path;

        if (!string.IsNullOrEmpty(loadedScenePath))
        {
            AkUtilities.FixSlashes(ref loadedScenePath, '\\', '/', false);
        }

        UnityEditor.SceneManagement.EditorSceneManager.NewScene(UnityEditor.SceneManagement.NewSceneSetup.DefaultGameObjects);

        // obtain a list of ScriptableObjects before any migration is performed
        ScriptableObjectGuids = UnityEditor.AssetDatabase.FindAssets("t:ScriptableObject", new[] { "Assets" });

        AkUtilities.BeginMigration(migrateStart);

        if (AkUtilities.IsMigrationRequired(AkUtilities.MigrationStep.NewScriptableObjectFolder_v2019_2_0))
        {
            var oldScriptableObjectPath = System.IO.Path.Combine(System.IO.Path.Combine("Assets", "Wwise"), "Resources");
            AkUtilities.MoveFolder(oldScriptableObjectPath, AkWwiseEditorSettings.WwiseScriptableObjectRelativePath);
        }

        AkWwiseProjectInfo.GetData().Migrate();
        AkWwiseWWUBuilder.UpdateWwiseObjectReferenceData();

        MigratePrefabs();
        MigrateScenes();
        MigrateScriptableObjects();

        UnityEditor.EditorUtility.UnloadUnusedAssetsImmediate();

        UnityEditor.SceneManagement.EditorSceneManager.NewScene(UnityEditor.SceneManagement.NewSceneSetup.DefaultGameObjects);
        AkUtilities.EndMigration();

        UpdateProgressBar(TotalNumberOfSections);

        // Reopen the scene that was opened before the migration process started.
        if (!string.IsNullOrEmpty(loadedScenePath))
        {
            UnityEditor.SceneManagement.EditorSceneManager.OpenScene(loadedScenePath);
        }

        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
        {
            // Ignore if not present.
        }

        UnityEditor.EditorUtility.ClearProgressBar();
    }