Networked Scenes
Scene IDs Update
First, your scenes must be referenced in a ScriptableObject. This Asset is created automatically in Assets/Wonderland/WonderlandNetSL.asset
.
This asset is automatically created/update You can change the path in
Project Settings/Wonderland
You can force update of the scene list inTools/Wonderland/Net/Force SceneList Update
NetScene
Create a GameObject with a NetScene
component. This is the base to make a scene joinable online.
GUID
Asset IDSUID
(scene id) is automatically assigned (using the scene list).Refresh UIDs
button forces the refresh of all NetworkedObjects.Version
. You can join an instantiated scene only if you have the same version.AutoJoin
. Auto joins online on scene load.
Manual Join
If AutoJoin is not enabled, use Join method to go online.
var sceneInstance = await GetComponent<NetScene>().Join();
if (sceneInstance.IsValid()) {
...
}
New instance
If you do not want Join an existing instance, you can force an instance creation.
SceneInstance instance = GetComponent<NetScene>().CreateNewInstance();
Join a specific instance
If the scene has many instances on the server you can join one with its ID.
var instance = NetManager.MakeSceneInstance(networkId); // networkId may be shared via network or other...
bool success = await GetComponent<NetScene>().Join(instance);
Scene id is not checked
Leave
This method is called automatically OnDestroy but you can force leave manually with it.
GetComponent<NetScene>().Leave().WrapErrors();