text
stringlengths 0
1.11k
|
|---|
// DiscoverAppController.cs
|
98 public void StartHost()
|
99 {
|
100 NUXManager.Instance.StartNux(
|
101 NUX_EXPERIENCE_KEY,
|
102 () => StartConnection(true));
|
103 }
|
StartHost() makes a call to the NUXController.cs script StartNux() method, which is itself dependent on the DiscoverAppController.cs script StartConnectionAsync() method:
|
// DiscoverAppController.cs
|
125 private async void StartConnectionAsync(bool isHost, GameMode mode = GameMode.Shared)
|
126 {
|
127 if (isHost) //if this is a host, create a new room
|
128 {
|
129 NetworkModalWindowController.Instance.ShowMessage("Loading Room");
|
130 _ = await m_mrSceneLoader.LoadScene();
|
131 }
|
132
|
133 SetupForNetworkRunner(); // DiscoverAppController.cs (this file), line 247, instantiate and configures the NetworkRunner
|
134 NetworkModalWindowController.Instance.ShowMessage("Connecting to Photon...");
|
135 ColocationDriverNetObj.OnColocationCompletedCallback += OnColocationReady;
|
136 ColocationDriverNetObj.SkipColocation = AvatarColocationManager.Instance.IsCurrentPlayerRemote;
|
137 await Connect(isHost, mode); // DiscoverAppController.cs (this file), line 142
|
138 }
|
The call to m_mrSceneLoader.LoadScene() is to the MRSceneLoader.cs script, which creates the initial scene.
|
// MRSceneLoader.cs
|
17 public async UniTask<bool> LoadScene()
|
18 {
|
19 if (!m_sceneLoaded)
|
20 {
|
21 m_sceneLoadingTask = new();
|
Set up the Session
|
The Connect(isHost, mode) method in DiscoverAppController.cs script sets up the session, sets up the game arguments as per the user selections, and then attempts to start the game using Runner.StartGame() (in this case, game refers to the initial room):
|
// DiscoverAppController.cs
|
139 await Connect(isHost, mode);
|
...
|
168 var joined = await Runner.StartGame(args);
|
Set up for Colocation
|
The Runner object is the NetworkRunner prefab, and part of the Fusion assembly. The OnConnectedToServer action in the DiscoverAppController.cs script spawns the ColocationDriverNetObj prefab (m_colocationPrefab).
|
// DiscoverAppController.cs
|
296 public void OnConnectedToServer(NetworkRunner runner)
|
297 {
|
298 NetworkModalWindowController.Instance.ShowMessage(
|
299 $"Connected To Photon Session: {runner.SessionInfo.Name}");
|
...
|
310 Debug.Log("Spawn Colocation Prefab");
|
311 _ = Runner.Spawn(m_colocationPrefab);
|
When spawned, the ColocationDriverNetObj.cs script issues an Init() call , which awaits completion of the SetUpForColocation() method.
|
// ColocationDriverNetObj.cs
|
72 private async void Init()
|
73 {
|
74 m_ovrCameraRigTransform = FindObjectOfType<OVRCameraRig>().transform;
|
75 m_oculusUser = await OculusPlatformUtils.GetLoggedInUser();
|
76 m_headsetGuid = Guid.NewGuid();
|
77 await SetupForColocation();
|
78 }
|
79
|
80 private async UniTask SetupForColocation()
|
81 {
|
82 if (HasStateAuthority)
|
83 {
|
84 Debug.Log("SetUpAndStartColocation for host");
|
The SetUpForColocation() method does a lot. Among other things, it kicks off and waits for the Photon Network. When that is ready, the method instantiates a SharedAnchorManager and an AlignmentAnchormanager, which are both key components in setting up the SSA.
|
// ColocationDriverNetObj.cs
|
100 var sharedAnchorManager = new SharedAnchorManager
|
101 {
|
102 AnchorPrefab = m_anchorPrefab
|
103 };
|
104
|
105 m_alignmentAnchorManager =
|
106 Instantiate(m_alignmentAnchorManagerPrefab).GetComponent<AlignmentAnchorManager>();
|
107
|
108 m_alignmentAnchorManager.Init(m_ovrCameraRigTransform);
|
With these available, it sets up the ColocationLauncher object:
|
// ColocationDriverNetObj.cs
|
116 m_colocationLauncher = new ColocationLauncher();
|
117 m_colocationLauncher.Init(
|
118 m_oculusUser?.ID ?? default,
|
119 m_headsetGuid,
|
120 NetworkAdapter.NetworkData,
|
121 NetworkAdapter.NetworkMessenger,
|
122 sharedAnchorManager,
|
123 m_alignmentAnchorManager,
|
124 overrideEventCode
|
125 );
|
Finally, it calls the method CreateColocatedSpace()
|
// ColocationDriverNetObj.cs
|
128 if (HasStateAuthority)
|
129 {
|
130 m_colocationLauncher.CreateColocatedSpace();
|
131 }
|
Launch the Colocated Space and Establish the SSA
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.