mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
Fix sceneID mismatch bug between build (buildIndex=-1) and editor (buildIndex=0) for projects where the scene was not added to build settings list
This commit is contained in:
parent
8642056f21
commit
62fc738673
@ -284,7 +284,13 @@ void AssignSceneID()
|
||||
public void SetSceneIdSceneIndexByteInternal()
|
||||
{
|
||||
// get build index
|
||||
byte buildIndex = (byte)gameObject.scene.buildIndex;
|
||||
// -> if the scene is not in build settings, then a build would
|
||||
// have buildIndex '-1', but pressing Play in the Editor would
|
||||
// have a buildIndex '0', which would always get sceneIds out of
|
||||
// sync if we didn't add the scene to build settings.
|
||||
// -> let's always use at least '0', which is what unity Editor does
|
||||
// internally as it seems.
|
||||
byte buildIndex = (byte)Mathf.Max(gameObject.scene.buildIndex, 0);
|
||||
|
||||
// OR into scene id
|
||||
m_SceneId = (m_SceneId & 0x00FFFFFF) | (uint)(buildIndex << 24);
|
||||
|
Loading…
Reference in New Issue
Block a user