|
Post by scornflake on Apr 4, 2022 22:44:19 GMT
There is no Master Audio prefab in this Scene. Subsequent method calls will fail.
I have a number of AmbientSound objects in scene.
I see that AmbientSound has a priority great than MA. So I don't understand why this is happening.
It doesn't happen in editor. Does happen in a Development Build. The scene uses Additive loading; and there is another MA instance in the other scene. Scenes are unloaded first; before the next scene is async loaded.
Any tips?
---
There is no Master Audio prefab in this Scene. Subsequent method calls will fail.
UnityEngine.StackTraceUtility:ExtractStackTrace ()
UnityEngine.DebugLogHandler:LogFormat (UnityEngine.LogType,UnityEngine.Object,string,object[])
UnityEngine.Logger:Log (UnityEngine.LogType,object)
UnityEngine.Debug:LogError (object)
DarkTonic.MasterAudio.MasterAudio:get_Instance () (at /Users/neil/jenkins/workspace/Be2_master_2/Assets/Plugins/DarkTonic/MasterAudio/Scripts/Singleton/MasterAudio.cs:8816)
DarkTonic.MasterAudio.MasterAudio:SetupAmbientNextFrame (DarkTonic.MasterAudio.AmbientSound) (at /Users/neil/jenkins/workspace/Be2_master_2/Assets/Plugins/DarkTonic/MasterAudio/Scripts/Singleton/MasterAudio.cs:8361)
DarkTonic.MasterAudio.AmbientSound:OnEnable () (at /Users/neil/jenkins/workspace/Be2_master_2/Assets/Plugins/DarkTonic/MasterAudio/Scripts/Events/AmbientSound.cs:39)
|
|
|
Post by DarkTonic Dev on Apr 4, 2022 23:12:31 GMT
I don't use (or know how to use) additive Scenes, so maybe it's particular to that? If you're saying the subsequent scene has a Master Audio game object in it, then get_Instance shouldn't be able to fail to find it. Also, it should fail just the same in the editor, so that makes no sense either.
Maybe you need to add some debugs to your Master Audio game object, to log when it's enabled / disabled, etc and see if that gives any clues.
You could also log whether instance in SafeInstance is null or not. Let me know what you find.
-B
|
|
|
Post by scornflake on Apr 6, 2022 10:48:01 GMT
OK. Struggling to understand what the problem is. I've attached a log, so you can use vscode (or similar). See attachments. I annotated MasterAudio so that it logged OnDestroy, Awake, and OnDisable. If you look at line 300, MA is being disabled as part of the scene unload (as we unload the game 'connection' scene, and prepare to load the real scene). Line 322 is I think the result of an explicit resource unload. To give context; here is the scene unload/load (async): private IEnumerator _SwitchToScene(bool connectionScene, Action thenDo)
{
var sceneToUnload = connectionScene ? ActualGameScene : StartOrConnect;
if (!string.IsNullOrEmpty(sceneToUnload) && IsAdditiveSceneLoaded(sceneToUnload))
{
SceneLoadEvents.Invoke(new SceneLoadInfo(!connectionScene, SceneLoadInfo.Stage.BeforeUnload, sceneToUnload, Path.GetFileName(sceneToUnload)));
yield return SceneManager.UnloadSceneAsync(sceneToUnload);
yield return new WaitForEndOfFrame();
yield return Resources.UnloadUnusedAssets();
SceneLoadEvents.Invoke(new SceneLoadInfo(!connectionScene, SceneLoadInfo.Stage.AfterUnload, sceneToUnload, Path.GetFileName(sceneToUnload)));
}
var sceneToLoad = connectionScene ? StartOrConnect : ActualGameScene;
if (!string.IsNullOrEmpty(sceneToLoad))
{
if (!IsAdditiveSceneLoaded(sceneToLoad))
{
SceneLoadEvents.Invoke(new SceneLoadInfo(connectionScene, SceneLoadInfo.Stage.BeforeLoad, sceneToLoad, Path.GetFileName(sceneToLoad)));
yield return SceneManager.LoadSceneAsync(sceneToLoad, LoadSceneMode.Additive);
yield return new WaitForEndOfFrame();
MakeLoadedSceneActive(sceneToLoad);
SceneLoadEvents.Invoke(new SceneLoadInfo(connectionScene, SceneLoadInfo.Stage.AfterLoad, sceneToLoad, Path.GetFileName(sceneToLoad)));
}
else
{
// just fire the events anyway
SceneLoadEvents.Invoke(new SceneLoadInfo(connectionScene, SceneLoadInfo.Stage.BeforeLoad, sceneToLoad, Path.GetFileName(sceneToLoad)));
SceneLoadEvents.Invoke(new SceneLoadInfo(connectionScene, SceneLoadInfo.Stage.AfterLoad, sceneToLoad, Path.GetFileName(sceneToLoad)));
}
} What we see on 308 is the result of "yield return Resources.UnloadUnusedAssets();" I think. (I cannot guarantee that) Then we see 325-335, the XR system come up (no origin is OK) Followed directly by 345: AmbientSound.OnEnable. Which is WWEEEEEIIIIIRD. Because the next log of "MasterAudio Instance in Awake" (what I added in Awake of MasterAudio.cs) appears 400 years later. It's almost like Unity isn't respecting script execution ordering, when loading additive. At this point I'm rubber ducking... just trying to show what I've done, and hopefully show I've been pretty careful to be reasonable/thorough about it. Staring at the log, I see TWO "MasterAudio Instance in Awake". Linnes 2565 and 2589. This is. Odd. and concerning. How could *that* happen. Right now I dunno if I'm looking at a Unity bug or me doing something stupid. Don't quite get how a MA behaviour could get TWO .Awake() calls tho. Tomorrow I may get a chance to look further. That's the digging I've done, up to now. Attachments:Player.log (274.99 KB)
|
|
|
Post by scornflake on Apr 6, 2022 10:52:09 GMT
Worse; I see two calls to "MasterAudio being Disabled". I'll need to dig more. Right now all I have is a shotgun shooting log lines into the air, with me looking on saying "... ohhh! pretty!"
|
|
|
Post by DarkTonic Dev on Apr 6, 2022 14:28:45 GMT
It does sound buggy. Awake being called twice? Let me know if you narrow it down.
|
|
|
Post by scornflake on Apr 8, 2022 2:46:29 GMT
Well. Stupid me. After all that debugging; I had dragged a 2nd MA prefab into my main scene, and not noticed. So. DUH. It's fine 
|
|
|
Post by DarkTonic Dev on Apr 8, 2022 3:18:45 GMT
Oh weird. Well in any case, I'm glad you figured it out!
|
|