Help/ErrorCode_UnknownGameObject #3
Replies: 1 comment
-
In Unity I've found a multi-scene workflow where the Wwise loading scene is not the active scene can cause issues regardless of the script execution order. An example script that sets the scene at buildIndex 0 to active when entering playmode, and sets another scene active in the other cases: using UnityEditor;
using UnityEngine.SceneManagement;
namespace Example
{
public static class WwiseLoadingHack
{
[InitializeOnLoadMethod]
private static void Register()
{
EditorApplication.playModeStateChanged -= OnPlayModeStateChanged;
EditorApplication.playModeStateChanged += OnPlayModeStateChanged;
}
private static void OnPlayModeStateChanged(PlayModeStateChange state)
{
switch (state)
{
case PlayModeStateChange.EnteredPlayMode:
case PlayModeStateChange.EnteredEditMode:
// Set the active scene to the one we actually care about
// after things have loaded, or when we return to the editor.
SetActiveScene(false);
break;
case PlayModeStateChange.ExitingEditMode:
// Set the active scene to the "core" scene so Wwise can initialise in the correct order.
SetActiveScene(true);
break;
case PlayModeStateChange.ExitingPlayMode:
break;
}
}
private static void SetActiveScene(bool zeroIndex)
{
for (int i = 0; i < SceneManager.sceneCount; i++)
{
Scene scene = SceneManager.GetSceneAt(i);
if (zeroIndex)
{
if (scene.buildIndex != 0)
continue;
}
else
{
if (scene.buildIndex == 0)
continue;
}
SceneManager.SetActiveScene(scene);
break;
}
}
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Help/ErrorCode_UnknownGameObject
Audiokinetic Wwise Help - Unknown/Dead game object ID used in . Make sure the game object is registered before using it and do not use it once it was unregistered.
https://www.audiokinetic.com/en/library/edge/?source=Help&id=ErrorCode_UnknownGameObject
Beta Was this translation helpful? Give feedback.
All reactions