IEnumerator DelayedAvatarInstantiation(object content, int senderid) { yield return(new WaitForSecondsRealtime(0.1f)); object[] instantiationData = (object[])content; //Create panel PhotonPlayer photonPlayer = PhotonPlayer.Find(senderid); GameObject go = null; int viewId = (int)instantiationData[0]; string oculusId = (string)instantiationData[1]; if (PhotonNetwork.player.ID == senderid) { go = Instantiate(m_LocalAvatarPrefab); m_PlayerAvatars.Add(photonPlayer.ID, go); _LocalAvatar = go; _LocalVoiceRecorder = PhotonNetwork.Instantiate("PhotonPlayerVoice", Vector3.zero, Quaternion.identity, 0).GetComponent <PhotonVoiceRecorder>(); _LocalVoiceRecorder.transform.SetParent(go.transform); _LocalAvatar.transform.SetParent(CameraController.CameraContainer.transform); } else { go = Instantiate(m_RemoteAvatarPrefab); m_PlayerAvatars.Add(photonPlayer.ID, go); } if (go != null) { PhotonView pView = go.GetComponent <PhotonView>(); if (pView != null) { pView.viewID = viewId; pView.ownerId = senderid; } OvrAvatar avatar = go.GetComponent <OvrAvatar>(); avatar.oculusUserID = oculusId; if (photonPlayer.IsLocal) { Fader.FadeInAll(); } m_PositionController.SetObjectPosition(go, (UserPosition)photonPlayer.CustomProperties["EnvironmentLocation"], (int)photonPlayer.CustomProperties["EnvironmentPositionIndex"]); if (!photonPlayer.IsLocal) { SetPlayerPosition(photonPlayer); } } }
private void SceneManagerOnSceneLoaded(Scene loadedScene, LoadSceneMode mode) { m_PositionController = FindObjectOfType <AlcovePositionController>(); PhotonNetwork.player.SetCustomProperties(new HashTable() { { "CurrentScene", loadedScene.name } }); if (loadedScene.name.Equals(AlcoveThirdPartyExperienceController.HomeEnvironmentSceneName)) { SetLocalAvatarParentToCameraRig(); } if (PhotonNetwork.room != null) { foreach (var photonPlayer in PhotonNetwork.playerList) { if (photonPlayer.IsLocal) { continue; } if (photonPlayer.CustomProperties.ContainsKey("CurrentScene") && loadedScene.name.Equals(photonPlayer.CustomProperties["CurrentScene"] as string, StringComparison.InvariantCultureIgnoreCase) && m_PlayerAvatars.ContainsKey(photonPlayer.ID)) { m_PlayerAvatars[photonPlayer.ID].GetComponent <OvrAvatar>().ShowThirdPerson = true; if (string.Equals(AlcoveThirdPartyExperienceController.HomeEnvironmentSceneName, photonPlayer.CustomProperties["CurrentScene"] as string, StringComparison.InvariantCultureIgnoreCase)) { SetPlayerPosition(photonPlayer); } } else if (m_PlayerAvatars.ContainsKey(photonPlayer.ID)) { m_PlayerAvatars[photonPlayer.ID].GetComponent <OvrAvatar>().ShowThirdPerson = false; } } } if (PhotonNetwork.room != null) { Fader.FadeInAll(); } }