Forum rules - please read before posting.

Play sound on additive scene by recorded constantID

Hello,

I am using multiple scenes and load them additively to separate the logic and environment so different team members can work on them separately.

Now I was able to remove an object by using constant ID on Object:Remove using recorded constant ID. the object is on another scene that is loaded additively but it is successfully removed

the problem occurs when I use a sound object

I simply use Sound:Play and attach the sound object with recorded constantID, again on another scene that is loaded additively. but this time this sound object does not play.

a workaround is setting the sound object for Play across scenes but a) I don't want this to carry on to other scenes and b) it asks the sound object to be moved out of the hierarchy so it has no parent GameObject. and I don't want to have hundreds of non-parented gameobject

I can simply carry the sound objects to the logic scene and it is solved but my brain wants to learn a solution for this.

Thanks

Comments

  • The Constant ID system has a built-in requirement that referenced objects are in the main/active scene. This is so that two objects with the same ID but in different scenes (by design) are not confused.

    I will think on this situation for how this workflow might be improved, but in the meantime you can open up UnityVersionHandler.cs and find the GetOwnSceneComponents function.

    Then, replace the first line of that function:

    T[] instances = Object.FindObjectsOfType (typeof (T)) as T[];
    

    with:

    T[] instances = Object.FindObjectsOfType (typeof (T)) as T[]; return instances;
    
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.