private void RegisterWithEmailCallback(AccountService client) { EditorUtility.ClearProgressBar(); if (client.ReturnCode == 0) { this.mailOrAppId = client.AppId; PhotonNetwork.PhotonServerSettings.UseCloud(this.mailOrAppId, null); if (PhotonEditorUtils.HasVoice) { PhotonNetwork.PhotonServerSettings.AppSettings.AppIdVoice = client.AppId2; } PhotonEditor.SaveSettings(); this.photonSetupState = PhotonSetupStates.GoEditPhotonServerSettings; } else { PhotonEditor.SaveSettings(); if (client.Message.Contains("registered")) { this.photonSetupState = PhotonSetupStates.EmailAlreadyRegistered; } else { EditorUtility.DisplayDialog(CurrentLang.ErrorTextTitle, client.Message, CurrentLang.OkButton); this.photonSetupState = PhotonSetupStates.RegisterForPhotonCloud; } } }
// called in editor, opens wizard for initial setup, keeps scene PhotonViews up to date and closes connections when compiling (to avoid issues) private static void OnProjectChanged() { // Prevent issues with Unity Cloud Builds where ServerSettings are not found. // Also, within the context of a Unity Cloud Build, ServerSettings is already present anyway. #if UNITY_CLOUD_BUILD return; #endif PunSceneSettings.SanitizeSceneSettings(); if (PhotonNetwork.PhotonServerSettings == null) { PhotonNetwork.CreateSettings(); if (PhotonNetwork.PhotonServerSettings == null) { Debug.LogError("CreateSettings() failed to create PhotonServerSettings."); return; } } // serverSetting is null when the file gets deleted. otherwise, the wizard should only run once and only if hosting option is not (yet) set if (!PhotonNetwork.PhotonServerSettings.DisableAutoOpenWizard) { ShowRegistrationWizard(); PhotonNetwork.PhotonServerSettings.DisableAutoOpenWizard = true; PhotonEditor.SaveSettings(); } }
// called in editor, opens wizard for initial setup, keeps scene PhotonViews up to date and closes connections when compiling (to avoid issues) private static void OnProjectChanged() { PhotonEditorUtils.ProjectChangedWasCalled = true; // Prevent issues with Unity Cloud Builds where ServerSettings are not found. // Also, within the context of a Unity Cloud Build, ServerSettings is already present anyway. #if UNITY_CLOUD_BUILD return; #endif if (PhotonNetwork.PhotonServerSettings == null || PhotonNetwork.PhotonServerSettings.AppSettings == null || string.IsNullOrEmpty(PhotonNetwork.PhotonServerSettings.AppSettings.AppIdRealtime)) { PhotonNetwork.LoadOrCreateSettings(true); } if (PhotonNetwork.PhotonServerSettings == null) { // the PhotonServerSettings are loaded or created. If both fails, the Editor should probably not run (anymore). return; } PunSceneSettings.SanitizeSceneSettings(); // serverSetting is null when the file gets deleted. otherwise, the wizard should only run once and only if hosting option is not (yet) set if (!PhotonNetwork.PhotonServerSettings.DisableAutoOpenWizard) { ShowRegistrationWizard(); PhotonNetwork.PhotonServerSettings.DisableAutoOpenWizard = true; PhotonEditor.SaveSettings(); } }
public static void UpdateRpcList() { List <string> additionalRpcs = new List <string>(); HashSet <string> currentRpcs = new HashSet <string>(); var types = GetAllSubTypesInScripts(typeof(MonoBehaviour)); foreach (var mono in types) { MethodInfo[] methods = mono.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); foreach (MethodInfo method in methods) { if (method.IsDefined(typeof(PunRPC), false)) { currentRpcs.Add(method.Name); if (!additionalRpcs.Contains(method.Name) && !PhotonNetwork.PhotonServerSettings.RpcList.Contains(method.Name)) { additionalRpcs.Add(method.Name); } } } } if (additionalRpcs.Count > 0) { // LIMITS RPC COUNT if (additionalRpcs.Count + PhotonNetwork.PhotonServerSettings.RpcList.Count >= byte.MaxValue) { if (currentRpcs.Count <= byte.MaxValue) { bool clearList = EditorUtility.DisplayDialog(CurrentLang.IncorrectRPCListTitle, CurrentLang.IncorrectRPCListLabel, CurrentLang.RemoveOutdatedRPCsLabel, CurrentLang.CancelButton); if (clearList) { PhotonNetwork.PhotonServerSettings.RpcList.Clear(); PhotonNetwork.PhotonServerSettings.RpcList.AddRange(currentRpcs); } else { return; } } else { EditorUtility.DisplayDialog(CurrentLang.FullRPCListTitle, CurrentLang.FullRPCListLabel, CurrentLang.SkipRPCListUpdateLabel); return; } } additionalRpcs.Sort(); Undo.RecordObject(PhotonNetwork.PhotonServerSettings, "Update PUN RPC-list"); PhotonNetwork.PhotonServerSettings.RpcList.AddRange(additionalRpcs); PhotonEditor.SaveSettings(); } }
private void RegisterWithEmailSuccessCallback(AccountServiceResponse res) { EditorUtility.ClearProgressBar(); this.emailSentToAccountIsRegistered = true; // email is either registered now, or was already if (res.ReturnCode == AccountServiceReturnCodes.Success) { string key = ((int)ServiceTypes.Pun).ToString(); string appId; if (res.ApplicationIds.TryGetValue(key, out appId)) { this.mailOrAppId = appId; PhotonNetwork.PhotonServerSettings.UseCloud(this.mailOrAppId, null); key = ((int)ServiceTypes.Chat).ToString(); if (res.ApplicationIds.TryGetValue(key, out appId)) { PhotonNetwork.PhotonServerSettings.AppSettings.AppIdChat = appId; } else if (PhotonEditorUtils.HasChat) { Debug.LogWarning("Registration successful but no Chat AppId returned"); } key = ((int)ServiceTypes.Voice).ToString(); if (res.ApplicationIds.TryGetValue(key, out appId)) { PhotonNetwork.PhotonServerSettings.AppSettings.AppIdVoice = appId; } else if (PhotonEditorUtils.HasVoice) { Debug.LogWarning("Registration successful but no Voice AppId returned"); } PhotonEditor.SaveSettings(); this.photonSetupState = PhotonSetupStates.GoEditPhotonServerSettings; } else { DisplayErrorMessage("Registration successful but no PUN AppId returned"); } } else { PhotonEditor.SaveSettings(); if (res.ReturnCode == AccountServiceReturnCodes.EmailAlreadyRegistered) { this.photonSetupState = PhotonSetupStates.EmailAlreadyRegistered; } else { DisplayErrorMessage(res.Message); } } }
protected virtual void RegisterWithEmail(string email) { EditorUtility.DisplayProgressBar(CurrentLang.ConnectionTitle, CurrentLang.ConnectionInfo, 0.5f); string accountServiceType = string.Empty; if (PhotonEditorUtils.HasVoice) { accountServiceType = "voice"; } AccountService client = new AccountService(); client.RegisterByEmail(email, RegisterOrigin, accountServiceType); // this is the synchronous variant using the static RegisterOrigin. "result" is in the client EditorUtility.ClearProgressBar(); if (client.ReturnCode == 0) { this.mailOrAppId = client.AppId; PhotonNetwork.PhotonServerSettings.UseCloud(this.mailOrAppId, null); if (PhotonEditorUtils.HasVoice) { PhotonNetwork.PhotonServerSettings.AppSettings.AppIdVoice = client.AppId2; } PhotonEditor.SaveSettings(); this.photonSetupState = PhotonSetupStates.GoEditPhotonServerSettings; } else { PhotonEditor.SaveSettings(); Debug.LogWarning(client.Message + " ReturnCode: " + client.ReturnCode); if (client.Message.Contains("registered")) { this.photonSetupState = PhotonSetupStates.EmailAlreadyRegistered; } else { EditorUtility.DisplayDialog(CurrentLang.ErrorTextTitle, client.Message, CurrentLang.OkButton); this.photonSetupState = PhotonSetupStates.RegisterForPhotonCloud; } } }
// called in editor, opens wizard for initial setup, keeps scene PhotonViews up to date and closes connections when compiling (to avoid issues) private static void OnProjectChanged() { if (PhotonNetwork.PhotonServerSettings == null) { PhotonNetwork.CreateSettings(); if (PhotonNetwork.PhotonServerSettings == null) { Debug.LogError("CreateSettings() failed to create PhotonServerSettings."); return; } } // serverSetting is null when the file gets deleted. otherwise, the wizard should only run once and only if hosting option is not (yet) set if (!PhotonNetwork.PhotonServerSettings.DisableAutoOpenWizard) { ShowRegistrationWizard(); PhotonNetwork.PhotonServerSettings.DisableAutoOpenWizard = true; PhotonEditor.SaveSettings(); } }
// called in editor, opens wizard for initial setup, keeps scene PhotonViews up to date and closes connections when compiling (to avoid issues) private static void EditorUpdate() { if (PhotonNetwork.PhotonServerSettings == null) { PhotonNetwork.CreateSettings(); } if (PhotonNetwork.PhotonServerSettings == null) { return; } // serverSetting is null when the file gets deleted. otherwise, the wizard should only run once and only if hosting option is not (yet) set if (!PhotonNetwork.PhotonServerSettings.DisableAutoOpenWizard) { ShowRegistrationWizard(); PhotonNetwork.PhotonServerSettings.DisableAutoOpenWizard = true; PhotonEditor.SaveSettings(); } // Workaround for TCP crash. Plus this surpresses any other recompile errors. if (EditorApplication.isCompiling) { if (PhotonNetwork.IsConnected) { if (lastWarning > EditorApplication.timeSinceStartup - 3) { // Prevent error spam Debug.LogWarning(CurrentLang.WarningPhotonDisconnect); lastWarning = EditorApplication.timeSinceStartup; } PhotonNetwork.Disconnect(); } } }
protected virtual void UiSetupApp() { GUI.skin.label.wordWrap = true; if (!this.isSetupWizard) { GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button(CurrentLang.MainMenuButton, GUILayout.ExpandWidth(false))) { this.photonSetupState = PhotonSetupStates.MainUi; } GUILayout.EndHorizontal(); } // setup header this.UiTitleBox(CurrentLang.SetupWizardTitle, BackgroundImage); // setup info text GUI.skin.label.richText = true; GUILayout.Label(CurrentLang.SetupWizardInfo); // input of appid or mail EditorGUILayout.Separator(); GUILayout.Label(CurrentLang.EmailOrAppIdLabel); this.minimumInput = false; this.useMail = false; this.useAppId = false; this.mailOrAppId = EditorGUILayout.TextField(this.mailOrAppId); if (!string.IsNullOrEmpty(this.mailOrAppId)) { this.mailOrAppId = this.mailOrAppId.Trim(); // note: we trim all input if (AccountService.IsValidEmail(this.mailOrAppId)) { // this should be a mail address this.minimumInput = true; this.useMail = this.minimumInput; } else if (ServerSettings.IsAppId(this.mailOrAppId)) { // this should be an appId this.minimumInput = true; this.useAppId = this.minimumInput; } } // button to skip setup GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button(CurrentLang.SkipButton, GUILayout.Width(100))) { this.photonSetupState = PhotonSetupStates.GoEditPhotonServerSettings; this.useSkip = true; this.useMail = false; this.useAppId = false; } // SETUP button EditorGUI.BeginDisabledGroup(!this.minimumInput); if (GUILayout.Button(CurrentLang.SetupButton, GUILayout.Width(100))) { this.useSkip = false; GUIUtility.keyboardControl = 0; if (this.useMail) { this.RegisterWithEmail(this.mailOrAppId); // sets state } if (this.useAppId) { this.photonSetupState = PhotonSetupStates.GoEditPhotonServerSettings; Undo.RecordObject(PhotonNetwork.PhotonServerSettings, "Update PhotonServerSettings for PUN"); PhotonNetwork.PhotonServerSettings.UseCloud(this.mailOrAppId); PhotonEditor.SaveSettings(); } } EditorGUI.EndDisabledGroup(); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); // existing account needs to fetch AppId online if (this.photonSetupState == PhotonSetupStates.EmailAlreadyRegistered) { // button to open dashboard and get the AppId GUILayout.Space(15); GUILayout.Label(CurrentLang.AlreadyRegisteredInfo); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button(new GUIContent(CurrentLang.OpenCloudDashboardText, CurrentLang.OpenCloudDashboardTooltip), GUILayout.Width(205))) { Application.OpenURL(string.Concat(UrlCloudDashboard, Uri.EscapeUriString(this.mailOrAppId))); this.mailOrAppId = string.Empty; } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } if (this.photonSetupState == PhotonSetupStates.GoEditPhotonServerSettings) { if (!this.highlightedSettings) { this.highlightedSettings = true; HighlightSettings(); } GUILayout.Space(15); if (this.useSkip) { GUILayout.Label(CurrentLang.SkipRegistrationInfo); } else if (this.useMail) { GUILayout.Label(CurrentLang.RegisteredNewAccountInfo); } else if (this.useAppId) { GUILayout.Label(CurrentLang.AppliedToSettingsInfo); } // setup-complete info GUILayout.Space(15); GUILayout.Label(CurrentLang.SetupCompleteInfo); // close window (done) GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button(CurrentLang.CloseWindowButton, GUILayout.Width(205))) { this.close = true; } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } GUI.skin.label.richText = false; }