Now, we want to share a collaborative virtual environment between users who don't all use the same platform.
The idea is to be able to instantiate the good navigation rig (the default desktop one or the XR one) according to the platform available for a user.
To do that, you must add a parameter to the "Arena" "GameManager" in order to transmit the 2 rig prefabs ("NavigationRig" and "XRNavigationRig").
So first, modify the "GameManager.cs" script in order to be able to manage several kinds of platforms:
Add a new field to be able to manage 2 kinds of platforms:
public Navigation questPrefab ;
public Navigation desktopPrefab ;
Navigation playerPrefab ;
GameObject rigGO ;
Then, in order to instantiate the good good navigation rig:
Add some code in the "Start" method:
...
DeviceType platformType = SystemInfo.deviceType ;
playerPrefab = desktopPrefab ;
if (platformType == DeviceType.Desktop) {
playerPrefab = desktopPrefab ;
} else {
playerPrefab = questPrefab ;
}
...
rigGO = PhotonNetwork.Instantiate (this.playerPrefab.name, new Vector3 (0f, 0.5f, 0f), Quaternion.identity, 0) ;
...
At this point, 2 users should be able to join the shared virtual environment with asymmetrical platforms.
To be able to determine some player preferences with any platform at run-time, the widgets of the "Launcher" scene must be made interactable by tools such as a "XRRayInteractor", and such tools must be available when needed (when the user uses a VR helmet).
First, the user interface of the "Launcher" must be changed:
The "Canvas" "Render Mode" must be set to "World Space"
The "Scale" of the "Rect Transform" should be reduced (approximatively divided by 100)
A "Tracked Device Graphic Raycaster" must be added to the "Canvas"
The "MainCamera" of the scene should be placed accordingly (approximatively at (0, 1.6, -10))
Second, you must add other components in the "Launcher" scene:
A "XR Interaction Manager"
A new "XR Origin (Action-based)": the simpler way to do it is to simply add a "XRNavigationRig" in the scene
Place this object at the same position than the main camera (approximatively at (0, 1.6, -10))
Third, you must change the atomatic connexion behaviour of the "launcher":
Remove the call to the "Connect" method that had been added previously in the "Start" method of the "Launcher.cs" script
Last, you should disable the "XRNavigationRig" when the system is in desktop mode:
Add some code in the "Awake" method of the "Launcher.cs" script:
DeviceType platformType = SystemInfo.deviceType ;
if (platformType == DeviceType.Desktop) {
XRNavigation xrn = (XRNavigation)FindObjectOfType (typeof(XRNavigation)) ;
if (xrn != null) xrn.gameObject.SetActive (false) ;
}
Now, you must be able to select some user preferences in XR mode as well as in desktop mode.