diff --git a/Assets/Scripts/Config.cs b/Assets/Scripts/Config.cs index 567540f5f..52abcd25b 100644 --- a/Assets/Scripts/Config.cs +++ b/Assets/Scripts/Config.cs @@ -124,12 +124,12 @@ private class UserConfigChange [NonSerialized] public bool m_QuickLoad = true; public SecretsConfig.ServiceAuthData GoogleSecrets => Secrets?[SecretsConfig.Service.Google]; - public SecretsConfig.ServiceAuthData SketchfabSecrets => Secrets[SecretsConfig.Service.Sketchfab]; - public SecretsConfig.ServiceAuthData OculusSecrets => Secrets[SecretsConfig.Service.Oculus]; - public SecretsConfig.ServiceAuthData OculusMobileSecrets => Secrets[SecretsConfig.Service.OculusMobile]; - public SecretsConfig.ServiceAuthData PimaxSecrets => Secrets[SecretsConfig.Service.Pimax]; - public SecretsConfig.ServiceAuthData PhotonFusionSecrets => Secrets[SecretsConfig.Service.PhotonFusion]; - public SecretsConfig.ServiceAuthData PhotonVoiceSecrets => Secrets[SecretsConfig.Service.PhotonVoice]; + public SecretsConfig.ServiceAuthData SketchfabSecrets => Secrets?[SecretsConfig.Service.Sketchfab]; + public SecretsConfig.ServiceAuthData OculusSecrets => Secrets?[SecretsConfig.Service.Oculus]; + public SecretsConfig.ServiceAuthData OculusMobileSecrets => Secrets?[SecretsConfig.Service.OculusMobile]; + public SecretsConfig.ServiceAuthData PimaxSecrets => Secrets?[SecretsConfig.Service.Pimax]; + public SecretsConfig.ServiceAuthData PhotonFusionSecrets => Secrets?[SecretsConfig.Service.PhotonFusion]; + public SecretsConfig.ServiceAuthData PhotonVoiceSecrets => Secrets?[SecretsConfig.Service.PhotonVoice]; public bool DisableAccountLogins; diff --git a/Assets/Scripts/Multiplayer/MultiplayerManager.cs b/Assets/Scripts/Multiplayer/MultiplayerManager.cs index 2293913e0..d59e8559d 100644 --- a/Assets/Scripts/Multiplayer/MultiplayerManager.cs +++ b/Assets/Scripts/Multiplayer/MultiplayerManager.cs @@ -118,7 +118,9 @@ void Awake() void Start() { #if OCULUS_SUPPORTED - OVRPlatform.Users.GetLoggedInUser().OnComplete((msg) => { + // GetLoggedInUser can return null + // if Oculus.Platform.Core isn't initialized + OVRPlatform.Users.GetLoggedInUser()?.OnComplete((msg) => { if (!msg.IsError) { myOculusUserId = msg.GetUser().ID; @@ -146,7 +148,7 @@ void Start() m_VoiceManager = new PhotonVoiceManager(this); if (m_VoiceManager != null) ControllerConsoleScript.m_Instance.AddNewLine("PhotonVoiceManager Loaded"); else ControllerConsoleScript.m_Instance.AddNewLine("PhotonVoiceManager Not Loaded"); -#endif +#endif break; default: return; @@ -299,7 +301,7 @@ public bool DoesRoomNameExist(string roomName) // Find the room with the given name RoomData? room = m_RoomData.FirstOrDefault(r => r.roomName == roomName); - // Room exists + // Room exists RoomData r = (RoomData)room; if (r.numPlayers == 0) isUserRoomOwner = true;// and is empty user becomes room owner else isUserRoomOwner = false; // not empty user is not the room owner @@ -399,9 +401,9 @@ void Update() void OnLocalPlayerJoined(int id, ITransientData playerData) { - // the user is the room owner if is the firt to get in + // the user is the room owner if is the firt to get in isUserRoomOwner = m_Manager.GetPlayerCount() == 1 ? true : false; - // if not room owner clear scene + // if not room owner clear scene if (!isUserRoomOwner) SketchMemoryScript.m_Instance.ClearMemory(); m_LocalPlayer = playerData; @@ -445,7 +447,7 @@ void OnPlayerLeft(int id) } } - // Reassign Ownership if needed + // Reassign Ownership if needed // Check if any remaining player is the room owner bool anyRoomOwner = m_RemotePlayers.Any(player => m_Manager.GetPlayerRoomOwnershipStatus(player.PlayerId)) || isUserRoomOwner; diff --git a/Assets/Scripts/Sharing/OAuth2Identity.cs b/Assets/Scripts/Sharing/OAuth2Identity.cs index a9e66905c..cfea48f6f 100644 --- a/Assets/Scripts/Sharing/OAuth2Identity.cs +++ b/Assets/Scripts/Sharing/OAuth2Identity.cs @@ -103,7 +103,7 @@ private static void LogOutAll() public bool IsGoogle => m_Service == SecretsConfig.Service.Google; public UserCredential UserCredential => m_CredentialRequest?.UserCredential; - private SecretsConfig.ServiceAuthData ServiceAuthData => App.Config.Secrets[m_Service]; + private SecretsConfig.ServiceAuthData ServiceAuthData => App.Config.Secrets?[m_Service]; public string ClientId => ServiceAuthData?.ClientId; private string ClientSecret => ServiceAuthData?.ClientSecret; diff --git a/Assets/Scripts/VrSdk.cs b/Assets/Scripts/VrSdk.cs index 16953fe57..6f01ae829 100644 --- a/Assets/Scripts/VrSdk.cs +++ b/Assets/Scripts/VrSdk.cs @@ -220,12 +220,12 @@ void Awake() cameraRig.disableEyeAnchorCameras = true; //Get Oculus ID - var appId = App.Config.OculusSecrets.ClientId; + var appId = App.Config.OculusSecrets?.ClientId; #if UNITY_ANDROID - appId = App.Config.OculusMobileSecrets.ClientId; + appId = App.Config.OculusMobileSecrets?.ClientId; #endif - if (Unity.XR.Oculus.Utils.GetSystemHeadsetType() != Unity.XR.Oculus.SystemHeadset.Oculus_Quest) + if (appId != null && Unity.XR.Oculus.Utils.GetSystemHeadsetType() != Unity.XR.Oculus.SystemHeadset.Oculus_Quest) { Oculus.Platform.Core.Initialize(appId); Oculus.Platform.UserAgeCategory.Get().OnComplete((msg) => {