protected virtual void OnGUI() { PhotonSetupStates oldGuiState = this.photonSetupState; // used to fix an annoying Editor input field issue: wont refresh until focus is changed. GUI.SetNextControlName(""); this.scrollPos = GUILayout.BeginScrollView(this.scrollPos); if (this.photonSetupState == PhotonSetupStates.MainUi) { UiMainWizard(); } else { UiSetupApp(); } GUILayout.EndScrollView(); if (oldGuiState != this.photonSetupState) { GUI.FocusControl(""); } }
protected virtual void RegisterWithEmail(string email) { EditorUtility.DisplayProgressBar(CurrentLang.ConnectionTitle, CurrentLang.ConnectionInfo, 0.5f); var client = new AccountService(); client.RegisterByEmail(email, RegisterOrigin); // 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, 0); PhotonEditor.SaveSettings(); this.photonSetupState = PhotonSetupStates.GoEditPhotonServerSettings; } else { PhotonNetwork.PhotonServerSettings.HostType = ServerSettings.HostingOption.PhotonCloud; PhotonEditor.SaveSettings(); Debug.LogWarning(client.Message); if (client.Message.Contains("registered")) { this.photonSetupState = PhotonSetupStates.EmailAlreadyRegistered; } else { EditorUtility.DisplayDialog(CurrentLang.ErrorTextTitle, client.Message, CurrentLang.OkButton); this.photonSetupState = PhotonSetupStates.RegisterForPhotonCloud; } } }
protected virtual void OnGuiSetupSelfhosting() { GUILayout.Label(CurrentLang.YourPhotonServerLabel); this.photonAddress = EditorGUILayout.TextField(CurrentLang.AddressIPLabel, this.photonAddress); this.photonPort = EditorGUILayout.IntField(CurrentLang.PortLabel, this.photonPort); EditorGUILayout.Separator(); GUILayout.BeginHorizontal(); if (GUILayout.Button(CurrentLang.CancelButton)) { GUIUtility.keyboardControl = 0; this.ReApplySettingsToWindow(); } if (GUILayout.Button(CurrentLang.SaveButton)) { GUIUtility.keyboardControl = 0; PhotonEditor.Current.UseMyServer(this.photonAddress, this.photonPort, null); PhotonEditor.Save(); EditorUtility.DisplayDialog(CurrentLang.SettingsSavedTitle, CurrentLang.SettingsSavedMessage, CurrentLang.OkButton); } GUILayout.EndHorizontal(); EditorGUILayout.Separator(); // license GUILayout.BeginHorizontal(); GUILayout.Label(CurrentLang.LicensesLabel, EditorStyles.boldLabel, GUILayout.Width(100)); if (GUILayout.Button(new GUIContent(CurrentLang.LicenseDownloadText, CurrentLang.LicenseDownloadTooltip))) { EditorUtility.OpenWithDefaultApp(UrlFreeLicense); } GUILayout.EndHorizontal(); GUILayout.Space(20); GUILayout.Label(CurrentLang.TryPhotonAppLabel); if (GUILayout.Button(CurrentLang.GetCloudAppButton)) { this.cloudAppId = string.Empty; this.photonSetupState = PhotonSetupStates.RegisterForPhotonCloud; } EditorGUILayout.Separator(); GUILayout.Label(CurrentLang.OwnHostCloudCompareLabel); if (GUILayout.Button(CurrentLang.ComparisonPageButton)) { Application.OpenURL(UrlCompare); } }
protected virtual void RegisterWithEmail(string email) { EditorUtility.DisplayProgressBar("Connecting", "Connecting to the account service..", 0.5f); var client = new AccountService(); client.RegisterByEmail(email, RegisterOrigin); // this is the synchronous variant using the static RegisterOrigin. "result" is in the client EditorUtility.ClearProgressBar(); if (client.ReturnCode == 0) { PhotonEditor.Current.UseCloud(client.AppId); PhotonEditor.Save(); this.ReApplySettingsToWindow(); this.photonSetupState = PhotonSetupStates.SetupPhotonCloud; } else { if (client.Message.Contains("Email already registered")) { this.photonSetupState = PhotonSetupStates.EmailAlreadyRegistered; } else { EditorUtility.DisplayDialog("Error", client.Message, "OK"); // Debug.Log(client.Exception); this.photonSetupState = PhotonSetupStates.RegisterForPhotonCloud; } } }
protected virtual void OnGUI() { PhotonSetupStates oldGuiState = this.photonSetupState; // used to fix an annoying Editor input field issue: wont refresh until focus is changed. GUI.SetNextControlName(""); this.scrollPos = GUILayout.BeginScrollView(this.scrollPos); if (this.guiState == GUIState.Uninitialized) { this.ReApplySettingsToWindow(); this.guiState = (PhotonEditor.Current.HostType == ServerSettings.HostingOption.NotSet) ? GUIState.Setup : GUIState.Main; } if (this.guiState == GUIState.Main) { this.OnGuiMainWizard(); } else { this.OnGuiRegisterCloudApp(); } GUILayout.EndScrollView(); if (oldGuiState != this.photonSetupState) { GUI.FocusControl(""); } }
protected virtual void OnGUI() { if (BackgroundImage == null) { BackgroundImage = AssetDatabase.LoadAssetAtPath("Assets/Photon Unity Networking/Editor/PhotonNetwork/background.jpg", typeof(Texture2D)) as Texture2D; } PhotonSetupStates oldGuiState = this.photonSetupState; // used to fix an annoying Editor input field issue: wont refresh until focus is changed. GUI.SetNextControlName(""); this.scrollPos = GUILayout.BeginScrollView(this.scrollPos); if (this.photonSetupState == PhotonSetupStates.MainUi) { UiMainWizard(); } else { UiSetupApp(); } GUILayout.EndScrollView(); if (oldGuiState != this.photonSetupState) { GUI.FocusControl(""); } }
protected virtual void RegisterWithEmail(string email) { EditorUtility.DisplayProgressBar(CurrentLang.ConnectionTitle, CurrentLang.ConnectionInfo, 0.5f); var client = new AccountService(); client.RegisterByEmail(email, RegisterOrigin); // this is the synchronous variant using the static RegisterOrigin. "result" is in the client EditorUtility.ClearProgressBar(); if (client.ReturnCode == 0) { PhotonEditor.Current.UseCloud(client.AppId, 0); PhotonEditor.Save(); this.ReApplySettingsToWindow(); this.photonSetupState = PhotonSetupStates.SetupPhotonCloud; } else { if (client.Message.Contains(CurrentLang.EmailInUseLabel)) { this.photonSetupState = PhotonSetupStates.EmailAlreadyRegistered; } else { EditorUtility.DisplayDialog(CurrentLang.ErrorTextTitle, client.Message, CurrentLang.OkButton); // Debug.Log(client.Exception); this.photonSetupState = PhotonSetupStates.RegisterForPhotonCloud; } } }
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; } } }
protected virtual void OnGuiSetupSelfhosting() { GUILayout.Label("Your Photon Server"); this.photonAddress = EditorGUILayout.TextField("Address/ip:", this.photonAddress); this.photonPort = EditorGUILayout.IntField("Port:", this.photonPort); EditorGUILayout.Separator(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Cancel")) { GUIUtility.keyboardControl = 0; this.ReApplySettingsToWindow(); } if (GUILayout.Button("Save")) { GUIUtility.keyboardControl = 0; PhotonEditor.Current.UseMyServer(this.photonAddress, this.photonPort, null); PhotonEditor.Save(); EditorUtility.DisplayDialog("Success", "Saved your settings.", "ok"); } GUILayout.EndHorizontal(); EditorGUILayout.Separator(); // license GUILayout.BeginHorizontal(); GUILayout.Label("Licenses", EditorStyles.boldLabel, GUILayout.Width(100)); if (GUILayout.Button(new GUIContent("Free License Download", "Get your free license for up to 100 concurrent players."))) { EditorUtility.OpenWithDefaultApp(UrlFreeLicense); } GUILayout.EndHorizontal(); GUILayout.Space(20); GUILayout.Label("Running my own server is too much hassle..\nI want to give Photon's free app a try."); if (GUILayout.Button("Get the free cloud app")) { this.cloudAppId = string.Empty; this.photonSetupState = PhotonSetupStates.RegisterForPhotonCloud; } EditorGUILayout.Separator(); GUILayout.Label("I am not quite sure how 'my own host' compares to 'cloud'."); if (GUILayout.Button("See comparison page")) { Application.OpenURL(UrlCompare); } }
protected virtual void OnGUI() { if (BackgroundImage == null) { string[] paths = AssetDatabase.FindAssets("PunGradient t:Texture2D"); if (paths != null && paths.Length > 0) { BackgroundImage = AssetDatabase.LoadAssetAtPath <Texture2D>(AssetDatabase.GUIDToAssetPath(paths[0])); } } PhotonSetupStates oldGuiState = this.photonSetupState; // used to fix an annoying Editor input field issue: wont refresh until focus is changed. GUI.SetNextControlName(string.Empty); this.scrollPos = GUILayout.BeginScrollView(this.scrollPos); if (this.photonSetupState == PhotonSetupStates.MainUi) { this.UiMainWizard(); } else { this.UiSetupApp(); } GUILayout.EndScrollView(); if (oldGuiState != this.photonSetupState) { GUI.FocusControl(string.Empty); } }
//3a void SetupCloudAppIdGui() { GUILayout.Label("Your APP ID:"); cloudAPPID = EditorGUILayout.TextField(cloudAPPID); GUILayout.BeginHorizontal(); if (GUILayout.Button("Cancel")) { GUIUtility.keyboardControl = 0; this.ReloadHostingSettingsFromFile(); } if (GUILayout.Button("Save")) { GUIUtility.keyboardControl = 0; ServerSetting.UseCloud(this.cloudAPPID); this.SavePhotonSettings(); EditorUtility.DisplayDialog("Success", "Saved your settings.", "ok"); } GUILayout.EndHorizontal(); EditorGUILayout.Separator(); GUILayout.Label("Running my app in the cloud was fun but...\nLet me setup my own Photon server."); if (GUILayout.Button("Switch to own host")) { this.photonIP = ServerSettings.DefaultServerAddress; this.photonPort = ServerSettings.DefaultMasterPort; photonSetupState = PhotonSetupStates._3b; } }
//3b void SetupSelfhostingGui() { GUILayout.Label("Your Photon Host"); photonIP = EditorGUILayout.TextField("IP:", photonIP); photonPort = EditorGUILayout.IntField("Port:", photonPort); //photonProtocol = (ExitGames.Client.Photon.ConnectionProtocol)EditorGUILayout.EnumPopup("Protocol:", photonProtocol); GUILayout.BeginHorizontal(); if (GUILayout.Button("Cancel")) { GUIUtility.keyboardControl = 0; this.ReloadHostingSettingsFromFile(); } if (GUILayout.Button("Save")) { GUIUtility.keyboardControl = 0; ServerSetting.UseMyServer(this.photonIP, this.photonPort, null); this.SavePhotonSettings(); EditorUtility.DisplayDialog("Success", "Saved your settings.", "ok"); } GUILayout.EndHorizontal(); EditorGUILayout.Separator(); GUILayout.Label("Running my own server is too much hassle..\nI want to give Photon's free app a try."); if (GUILayout.Button("Get the free cloud app")) { this.cloudAPPID = ""; photonSetupState = PhotonSetupStates._1; } }
protected virtual void RegisterWithEmail(string email) { AccountService client = new AccountService(); client.CustomToken = CustomToken; client.CustomContext = CustomContext; List <ServiceTypes> types = new List <ServiceTypes>(); types.Add(ServiceTypes.Pun); if (PhotonEditorUtils.HasChat) { types.Add(ServiceTypes.Chat); } if (PhotonEditorUtils.HasVoice) { types.Add(ServiceTypes.Voice); } if (client.RegisterByEmail(email, types, RegisterWithEmailSuccessCallback, RegisterWithEmailErrorCallback)) { this.photonSetupState = PhotonSetupStates.EmailRegistrationPending; EditorUtility.DisplayProgressBar(CurrentLang.ConnectionTitle, CurrentLang.ConnectionInfo, 0.5f); } else { this.DisplayErrorMessage("Email registration request could not be sent. Retry again or check error logs and contact support."); } }
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); } } }
/// <summary>Re-initializes the Photon Setup window and shows one of three states: register cloud, setup cloud, setup self-hosted.</summary> protected void InitPhotonSetupWindow() { this.minSize = this.preferredSize; this.SwitchMenuState(GUIState.Setup); switch (PhotonNetwork.PhotonServerSettings.HostType) { case ServerSettings.HostingOption.PhotonCloud: case ServerSettings.HostingOption.BestRegion: default: this.photonSetupState = PhotonSetupStates.RegisterForPhotonCloud; break; } }
protected virtual void RegisterWithEmail(string email) { List <ServiceTypes> types = new List <ServiceTypes>(); types.Add(ServiceTypes.Pun); if (PhotonEditorUtils.HasChat) { types.Add(ServiceTypes.Chat); } if (PhotonEditorUtils.HasVoice) { types.Add(ServiceTypes.Voice); } if (this.serviceClient == null) { this.serviceClient = new AccountService(); this.serviceClient.CustomToken = CustomToken; this.serviceClient.CustomContext = CustomContext; } else { // while RegisterByEmail will check RequestPendingResult below, it would also display an error message. no needed in this case if (this.serviceClient.RequestPendingResult) { Debug.LogWarning("Registration request is pending a response. Please wait."); return; } } this.emailSentToAccount = email; this.emailSentToAccountIsRegistered = false; if (this.serviceClient.RegisterByEmail(email, types, RegisterWithEmailSuccessCallback, RegisterWithEmailErrorCallback)) { this.photonSetupState = PhotonSetupStates.EmailRegistrationPending; EditorUtility.DisplayProgressBar(CurrentLang.ConnectionTitle, CurrentLang.ConnectionInfo, 0.5f); } else { this.DisplayErrorMessage("Email registration request could not be sent. Retry again or check error logs and contact support."); } }
void RegisterWithEmail(string email) { EditorUtility.DisplayProgressBar("Connecting", "Connecting to the account service..", 0.5f); var client = new AccountService(UrlAccountService); Result defaultResult = new Result() { ReturnCode = -1, Message = "Account Service not available. Please use web-access and 'manual' setup." }; Result result = defaultResult; try { result = client.RegisterByEmail(email); } catch (Exception e) { Debug.LogError("Error trying to reach the cloud account service. Please use web-access." + e); } if (result == null) { result = defaultResult; } EditorUtility.ClearProgressBar(); if (result.ReturnCode == 0) { ServerSetting.UseCloud(result.Message); this.SavePhotonSettings(); this.ReloadHostingSettingsFromFile(); this.photonSetupState = PhotonSetupStates._3a; } else { if (result.Message.Contains("Email already registered")) { this.photonSetupState = PhotonSetupStates._2; } else { EditorUtility.DisplayDialog("Error", result.Message, "OK"); } } }
// SETUP GUI void OpenSetup() { SwitchMenuState(GUIState.Setup); this.ReloadHostingSettingsFromFile(); switch (ServerSetting.HostType) { case ServerSettings.HostingOption.PhotonCloud: photonSetupState = PhotonSetupStates._3a; break; case ServerSettings.HostingOption.SelfHosted: photonSetupState = PhotonSetupStates._3b; break; case ServerSettings.HostingOption.NotSet: default: photonSetupState = PhotonSetupStates._1; break; } }
/// <summary>Re-initializes the Photon Setup window and shows one of three states: register cloud, setup cloud, setup self-hosted.</summary> protected void InitPhotonSetupWindow() { this.SwitchMenuState(GUIState.Setup); this.ReApplySettingsToWindow(); switch (PhotonEditor.Current.HostType) { case ServerSettings.HostingOption.PhotonCloud: this.photonSetupState = PhotonSetupStates.SetupPhotonCloud; break; case ServerSettings.HostingOption.SelfHosted: this.photonSetupState = PhotonSetupStates.SetupSelfHosted; break; case ServerSettings.HostingOption.NotSet: default: this.photonSetupState = PhotonSetupStates.RegisterForPhotonCloud; break; } }
protected virtual void OnGuiSetupSelfhosting() { GUILayout.Label("Your Photon Host"); this.photonAddress = EditorGUILayout.TextField("IP:", this.photonAddress); this.photonPort = EditorGUILayout.IntField("Port:", this.photonPort); // photonProtocol = (ExitGames.Client.Photon.ConnectionProtocol)EditorGUILayout.EnumPopup("Protocol:", photonProtocol); GUILayout.BeginHorizontal(); if (GUILayout.Button("Cancel")) { GUIUtility.keyboardControl = 0; this.ReApplySettingsToWindow(); } if (GUILayout.Button("Save")) { GUIUtility.keyboardControl = 0; PhotonEditor.Current.UseMyServer(this.photonAddress, this.photonPort, null); PhotonEditor.Save(); EditorUtility.DisplayDialog("Success", "Saved your settings.", "ok"); } GUILayout.EndHorizontal(); EditorGUILayout.Separator(); GUILayout.Label("Running my own server is too much hassle..\nI want to give Photon's free app a try."); if (GUILayout.Button("Get the free cloud app")) { this.cloudAppId = string.Empty; this.photonSetupState = PhotonSetupStates.RegisterForPhotonCloud; } }
protected virtual void OnGuiSetupCloudAppId() { GUILayout.Label("Your APP ID:"); this.cloudAppId = EditorGUILayout.TextField(this.cloudAppId); GUILayout.BeginHorizontal(); if (GUILayout.Button("Cancel")) { GUIUtility.keyboardControl = 0; this.ReApplySettingsToWindow(); } if (GUILayout.Button("Save")) { GUIUtility.keyboardControl = 0; PhotonEditor.Current.UseCloud(this.cloudAppId); PhotonEditor.Save(); EditorUtility.DisplayDialog("Success", "Saved your settings.", "ok"); } GUILayout.EndHorizontal(); EditorGUILayout.Separator(); GUILayout.Label("Running my app in the cloud was fun but...\nLet me setup my own Photon server."); if (GUILayout.Button("Switch to own host")) { this.photonAddress = ServerSettings.DefaultServerAddress; this.photonPort = ServerSettings.DefaultMasterPort; this.photonSetupState = PhotonSetupStates.SetupSelfHosted; } }
private void DisplayErrorMessage(string error) { EditorUtility.DisplayDialog(CurrentLang.ErrorTextTitle, error, CurrentLang.OkButton); this.photonSetupState = PhotonSetupStates.RegisterForPhotonCloud; }
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; }
protected virtual void RegisterWithEmail(string email) { EditorUtility.DisplayProgressBar(CurrentLang.ConnectionTitle, CurrentLang.ConnectionInfo, 0.5f); var client = new AccountService(); client.RegisterByEmail(email, RegisterOrigin); // this is the synchronous variant using the static RegisterOrigin. "result" is in the client EditorUtility.ClearProgressBar(); if (client.ReturnCode == 0) { PhotonEditor.Current.UseCloud(client.AppId, 0); PhotonEditor.Save(); this.ReApplySettingsToWindow(); this.photonSetupState = PhotonSetupStates.SetupPhotonCloud; } else { if (client.Message.Contains(CurrentLang.EmailInUseLabel)) { this.photonSetupState = PhotonSetupStates.EmailAlreadyRegistered; } else { EditorUtility.DisplayDialog(CurrentLang.ErrorTextTitle, client.Message, CurrentLang.OkButton); // Debug.Log(client.Exception); this.photonSetupState = PhotonSetupStates.RegisterForPhotonCloud; } } }
protected virtual void OnGuiSetupCloudAppId() { GUILayout.Label(CurrentLang.AppIdLabel); GUILayout.BeginHorizontal(); this.cloudAppId = EditorGUILayout.TextField(this.cloudAppId); open = GUILayout.Toggle(open, HelpIcon, GUIStyle.none, GUILayout.ExpandWidth(false)); GUILayout.EndHorizontal(); if (open) GUILayout.Label(CurrentLang.AppIdInfoLabel); EditorGUILayout.Separator(); GUILayout.Label(CurrentLang.CloudRegionLabel); GUILayout.BeginHorizontal(); int toolbarValue = GUILayout.Toolbar((int)selectedRegion, CloudServerRegionNames); // the enum CloudRegionCode is converted into a string[] in init (toolbar can't use enum) helpRegion = GUILayout.Toggle(helpRegion, HelpIcon, GUIStyle.none, GUILayout.ExpandWidth(false)); GUILayout.EndHorizontal(); if (helpRegion) GUILayout.Label(CurrentLang.RegionalServersInfo); PhotonEditor.selectedRegion = (CloudRegionCode)toolbarValue; EditorGUILayout.Separator(); GUILayout.BeginHorizontal(); if (GUILayout.Button(CurrentLang.CancelButton)) { GUIUtility.keyboardControl = 0; this.ReApplySettingsToWindow(); } if (GUILayout.Button(CurrentLang.SaveButton)) { GUIUtility.keyboardControl = 0; this.cloudAppId = this.cloudAppId.Trim(); PhotonEditor.Current.UseCloud(this.cloudAppId); PhotonEditor.Current.PreferredRegion = PhotonEditor.selectedRegion; PhotonEditor.Current.HostType = (PhotonEditor.Current.PreferredRegion == CloudRegionCode.none) ? ServerSettings.HostingOption.BestRegion : ServerSettings.HostingOption.PhotonCloud; PhotonEditor.Save(); Inspect(); EditorUtility.DisplayDialog(CurrentLang.SettingsSavedTitle, CurrentLang.SettingsSavedMessage, CurrentLang.OkButton); } GUILayout.EndHorizontal(); GUILayout.Space(20); GUILayout.Label(CurrentLang.SetupOwnServerLabel); if (GUILayout.Button(CurrentLang.SelfHostSettingsButton)) { //this.photonAddress = ServerSettings.DefaultServerAddress; //this.photonPort = ServerSettings.DefaultMasterPort; this.photonSetupState = PhotonSetupStates.SetupSelfHosted; } EditorGUILayout.Separator(); GUILayout.Label(CurrentLang.OwnHostCloudCompareLabel); if (GUILayout.Button(CurrentLang.ComparisonPageButton)) { Application.OpenURL(UrlCompare); } }
/// <summary>Re-initializes the Photon Setup window and shows one of three states: register cloud, setup cloud, setup self-hosted.</summary> protected void InitPhotonSetupWindow() { this.minSize = MinSize; this.SwitchMenuState(GUIState.Setup); this.ReApplySettingsToWindow(); switch (PhotonEditor.Current.HostType) { case ServerSettings.HostingOption.PhotonCloud: case ServerSettings.HostingOption.BestRegion: this.photonSetupState = PhotonSetupStates.SetupPhotonCloud; break; case ServerSettings.HostingOption.SelfHosted: this.photonSetupState = PhotonSetupStates.SetupSelfHosted; break; case ServerSettings.HostingOption.NotSet: default: this.photonSetupState = PhotonSetupStates.RegisterForPhotonCloud; break; } }
protected virtual void UiMainWizard() { GUILayout.Space(15); // title UiTitleBox(CurrentLang.PUNWizardLabel, BackgroundImage); // wizard info text GUILayout.Label(CurrentLang.WizardMainWindowInfo); GUILayout.Space(15); // pun+ info if (isPunPlus) { GUILayout.Label(CurrentLang.MobilePunPlusExportNoteLabel); GUILayout.Space(15); } #if !(UNITY_5_0 || UNITY_5) else if (!InternalEditorUtility.HasAdvancedLicenseOnBuildTarget(BuildTarget.Android) || !InternalEditorUtility.HasAdvancedLicenseOnBuildTarget(BuildTarget.iPhone)) { GUILayout.Label(CurrentLang.MobileExportNoteLabel); GUILayout.Space(15); } #endif // settings button GUILayout.BeginHorizontal(); GUILayout.Label(CurrentLang.SettingsButton, EditorStyles.boldLabel, GUILayout.Width(100)); GUILayout.BeginVertical(); if (GUILayout.Button(new GUIContent(CurrentLang.LocateSettingsButton, CurrentLang.SettingsHighlightLabel))) { HighlightSettings(); } if (GUILayout.Button(new GUIContent(CurrentLang.OpenCloudDashboardText, CurrentLang.OpenCloudDashboardTooltip))) { Application.OpenURL(UrlCloudDashboard + Uri.EscapeUriString(this.mailOrAppId)); } if (GUILayout.Button(new GUIContent(CurrentLang.SetupButton, CurrentLang.SetupServerCloudLabel))) { this.photonSetupState = PhotonSetupStates.RegisterForPhotonCloud; } GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.Space(15); // converter GUILayout.BeginHorizontal(); GUILayout.Label(CurrentLang.ConverterLabel, EditorStyles.boldLabel, GUILayout.Width(100)); if (GUILayout.Button(new GUIContent(CurrentLang.StartButton, CurrentLang.UNtoPUNLabel))) { PhotonConverter.RunConversion(); } GUILayout.EndHorizontal(); EditorGUILayout.Separator(); // documentation GUILayout.BeginHorizontal(); GUILayout.Label(CurrentLang.DocumentationLabel, EditorStyles.boldLabel, GUILayout.Width(100)); GUILayout.BeginVertical(); if (GUILayout.Button(new GUIContent(CurrentLang.OpenPDFText, CurrentLang.OpenPDFTooltip))) { EditorUtility.OpenWithDefaultApp(DocumentationLocation); } if (GUILayout.Button(new GUIContent(CurrentLang.OpenDevNetText, CurrentLang.OpenDevNetTooltip))) { Application.OpenURL(UrlDevNet); } GUI.skin.label.wordWrap = true; GUILayout.Label(CurrentLang.OwnHostCloudCompareLabel); if (GUILayout.Button(CurrentLang.ComparisonPageButton)) { Application.OpenURL(UrlCompare); } if (GUILayout.Button(new GUIContent(CurrentLang.OpenForumText, CurrentLang.OpenForumTooltip))) { Application.OpenURL(UrlForum); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); }
protected virtual void OnGuiSetupSelfhosting() { GUILayout.Label("Your Photon Server"); this.photonAddress = EditorGUILayout.TextField("Address/ip:", this.photonAddress); this.photonPort = EditorGUILayout.IntField("Port:", this.photonPort); EditorGUILayout.Separator(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Cancel")) { GUIUtility.keyboardControl = 0; this.ReApplySettingsToWindow(); } if (GUILayout.Button("Save")) { GUIUtility.keyboardControl = 0; PhotonEditor.Current.UseMyServer(this.photonAddress, this.photonPort, null); PhotonEditor.Save(); EditorUtility.DisplayDialog("Success", "Saved your settings.", "ok"); } GUILayout.EndHorizontal(); EditorGUILayout.Separator(); // license GUILayout.BeginHorizontal(); GUILayout.Label("Licenses", EditorStyles.boldLabel, GUILayout.Width(100)); if (GUILayout.Button(new GUIContent("Free License Download", "Get your free license for up to 100 concurrent players."))) { EditorUtility.OpenWithDefaultApp(UrlFreeLicense); } GUILayout.EndHorizontal(); GUILayout.Space(20); GUILayout.Label("Running my own server is too much hassle..\nI want to give Photon's free app a try."); if (GUILayout.Button("Get the free cloud app")) { this.cloudAppId = string.Empty; this.photonSetupState = PhotonSetupStates.RegisterForPhotonCloud; } EditorGUILayout.Separator(); GUILayout.Label("I am not quite sure how 'my own host' compares to 'cloud'."); if (GUILayout.Button("See comparison page")) { Application.OpenURL(UrlCompare); } }
protected virtual void OnGuiSetupSelfhosting() { GUILayout.Label("Your Photon Host"); this.photonAddress = EditorGUILayout.TextField("IP:", this.photonAddress); this.photonPort = EditorGUILayout.IntField("Port:", this.photonPort); // photonProtocol = (ExitGames.Client.Photon.ConnectionProtocol)EditorGUILayout.EnumPopup("Protocol:", photonProtocol); GUILayout.BeginHorizontal(); if (GUILayout.Button("Cancel")) { GUIUtility.keyboardControl = 0; this.ReApplySettingsToWindow(); } if (GUILayout.Button("Save")) { GUIUtility.keyboardControl = 0; PhotonEditor.Current.UseMyServer(this.photonAddress, this.photonPort, null); PhotonEditor.Save(); EditorUtility.DisplayDialog("Success", "Saved your settings.", "ok"); } GUILayout.EndHorizontal(); EditorGUILayout.Separator(); GUILayout.Label("Running my own server is too much hassle..\nI want to give Photon's free app a try."); if (GUILayout.Button("Get the free cloud app")) { this.cloudAppId = string.Empty; this.photonSetupState = PhotonSetupStates.RegisterForPhotonCloud; } }
protected virtual void OnGuiSetupCloudAppId() { GUILayout.Label("Your APP ID:"); this.cloudAppId = EditorGUILayout.TextField(this.cloudAppId); GUILayout.BeginHorizontal(); if (GUILayout.Button("Cancel")) { GUIUtility.keyboardControl = 0; this.ReApplySettingsToWindow(); } if (GUILayout.Button("Save")) { GUIUtility.keyboardControl = 0; PhotonEditor.Current.UseCloud(this.cloudAppId); PhotonEditor.Save(); EditorUtility.DisplayDialog("Success", "Saved your settings.", "ok"); } GUILayout.EndHorizontal(); EditorGUILayout.Separator(); GUILayout.Label("Running my app in the cloud was fun but...\nLet me setup my own Photon server."); if (GUILayout.Button("Switch to own host")) { this.photonAddress = ServerSettings.DefaultServerAddress; this.photonPort = ServerSettings.DefaultMasterPort; this.photonSetupState = PhotonSetupStates.SetupSelfHosted; } }
protected virtual void OnGuiRegisterCloudApp() { GUI.skin.label.wordWrap = true; if (!this.isSetupWizard) { GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Close setup", GUILayout.ExpandWidth(false))) { this.SwitchMenuState(GUIState.Main); } GUILayout.EndHorizontal(); GUILayout.Space(15); } if (this.photonSetupState == PhotonSetupStates.RegisterForPhotonCloud) { GUI.skin.label.fontStyle = FontStyle.Bold; GUILayout.Label("Connect to Photon Cloud"); GUI.skin.label.fontStyle = FontStyle.Normal; GUILayout.Label("Your e-mail address is required to access your own free app."); this.emailAddress = EditorGUILayout.TextField("Email:", this.emailAddress); if (GUILayout.Button("Send")) { GUIUtility.keyboardControl = 0; this.RegisterWithEmail(this.emailAddress); } EditorGUILayout.Separator(); GUILayout.Label("I am already signed up. Let me enter my AppId."); if (GUILayout.Button("Setup")) { this.photonSetupState = PhotonSetupStates.SetupPhotonCloud; } GUILayout.Label("I want to register by a website."); if (GUILayout.Button("Open account website")) { EditorUtility.OpenWithDefaultApp(UrlAccountPage + Uri.EscapeUriString(this.emailAddress)); } EditorGUILayout.Separator(); } else if (this.photonSetupState == PhotonSetupStates.EmailAlreadyRegistered) { GUI.skin.label.fontStyle = FontStyle.Bold; GUILayout.Label("Oops!"); GUI.skin.label.fontStyle = FontStyle.Normal; GUILayout.Label("The provided e-mail-address has already been registered."); if (GUILayout.Button("Mh, see my account page")) { EditorUtility.OpenWithDefaultApp(UrlAccountPage + Uri.EscapeUriString(this.emailAddress)); } EditorGUILayout.Separator(); GUILayout.Label("Ah, I know my Application ID. Get me to setup."); GUILayout.BeginHorizontal(); if (GUILayout.Button("Cancel")) { this.photonSetupState = PhotonSetupStates.RegisterForPhotonCloud; } if (GUILayout.Button("Setup")) { this.photonSetupState = PhotonSetupStates.SetupPhotonCloud; } GUILayout.EndHorizontal(); } else if (this.photonSetupState == PhotonSetupStates.SetupPhotonCloud) { // cloud setup GUI.skin.label.fontStyle = FontStyle.Bold; GUILayout.Label("Connect to Photon Cloud"); GUI.skin.label.fontStyle = FontStyle.Normal; EditorGUILayout.Separator(); this.OnGuiSetupCloudAppId(); this.OnGuiCompareAndHelpOptions(); } else if (this.photonSetupState == PhotonSetupStates.SetupSelfHosted) { // self-hosting setup GUI.skin.label.fontStyle = FontStyle.Bold; GUILayout.Label("Setup own Photon Host"); GUI.skin.label.fontStyle = FontStyle.Normal; EditorGUILayout.Separator(); this.OnGuiSetupSelfhosting(); this.OnGuiCompareAndHelpOptions(); } }
protected virtual void OnGuiSetupCloudAppId() { GUILayout.Label(CurrentLang.AppIdLabel); GUILayout.BeginHorizontal(); this.cloudAppId = EditorGUILayout.TextField(this.cloudAppId); open = GUILayout.Toggle(open, HelpIcon, GUIStyle.none, GUILayout.ExpandWidth(false)); GUILayout.EndHorizontal(); if (open) { GUILayout.Label(CurrentLang.AppIdInfoLabel); } EditorGUILayout.Separator(); GUILayout.Label(CurrentLang.CloudRegionLabel); int selectedRegion = ServerSettings.FindRegionForServerAddress(this.photonAddress); GUILayout.BeginHorizontal(); int toolbarValue = GUILayout.Toolbar(selectedRegion, cloudServerRegionNames); // the enum CloudServerRegion is converted into a string[] in init (toolbar can't use enum) helpRegion = GUILayout.Toggle(helpRegion, HelpIcon, GUIStyle.none, GUILayout.ExpandWidth(false)); GUILayout.EndHorizontal(); if (helpRegion) { GUILayout.Label(CurrentLang.RegionalServersInfo); } if (selectedRegion != toolbarValue) { //Debug.Log("Replacing region: " + selectedRegion + " with: " + toolbarValue); this.photonAddress = ServerSettings.FindServerAddressForRegion(toolbarValue); } EditorGUILayout.Separator(); GUILayout.BeginHorizontal(); if (GUILayout.Button(CurrentLang.CancelButton)) { GUIUtility.keyboardControl = 0; this.ReApplySettingsToWindow(); } if (GUILayout.Button(CurrentLang.SaveButton)) { GUIUtility.keyboardControl = 0; this.cloudAppId = this.cloudAppId.Trim(); PhotonEditor.Current.UseCloud(this.cloudAppId, selectedRegion); PhotonEditor.Save(); EditorUtility.DisplayDialog(CurrentLang.SettingsSavedTitle, CurrentLang.SettingsSavedMessage, CurrentLang.OkButton); } GUILayout.EndHorizontal(); GUILayout.Space(20); GUILayout.Label(CurrentLang.SetupOwnServerLabel); if (GUILayout.Button(CurrentLang.SelfHostSettingsButton)) { this.photonAddress = ServerSettings.DefaultServerAddress; this.photonPort = ServerSettings.DefaultMasterPort; this.photonSetupState = PhotonSetupStates.SetupSelfHosted; } EditorGUILayout.Separator(); GUILayout.Label(CurrentLang.OwnHostCloudCompareLabel); if (GUILayout.Button(CurrentLang.ComparisonPageButton)) { Application.OpenURL(UrlCompare); } }
//3b void SetupSelfhostingGui() { GUILayout.Label("Your Photon Host"); photonIP = EditorGUILayout.TextField("IP:", photonIP); photonPort = EditorGUILayout.IntField("Port:", photonPort); //photonProtocol = (ExitGames.Client.Photon.ConnectionProtocol)EditorGUILayout.EnumPopup("Protocol:", photonProtocol); GUILayout.BeginHorizontal(); if (GUILayout.Button("Cancel")) { GUIUtility.keyboardControl = 0; this.ReloadHostingSettingsFromFile(); } if (GUILayout.Button("Save")) { GUIUtility.keyboardControl = 0; ServerSetting.UseMyServer(this.photonIP, this.photonPort, null); this.SavePhotonSettings(); EditorUtility.DisplayDialog("Success", "Saved your settings.", "ok"); } GUILayout.EndHorizontal(); EditorGUILayout.Separator(); GUILayout.Label("Running my own server is too much hassle..\nI want to give Photon's free app a try."); if (GUILayout.Button("Get the free cloud app")) { this.cloudAPPID = ""; photonSetupState = PhotonSetupStates._1; } }
void SetupGUI() { GUI.skin.label.wordWrap = true; if (!isSetupWizard) { GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Close setup", GUILayout.ExpandWidth(false))) SwitchMenuState(GUIState.Main); GUILayout.EndHorizontal(); GUILayout.Space(15); } if (photonSetupState == PhotonSetupStates._1) { GUI.skin.label.fontStyle = FontStyle.Bold; GUILayout.Label("Connect to Photon Cloud"); GUI.skin.label.fontStyle = FontStyle.Normal; GUILayout.Label("Your e-mail address is required to access your own free app."); emailAddress = EditorGUILayout.TextField("Email:", emailAddress); if (GUILayout.Button("Send")) { GUIUtility.keyboardControl = 0; RegisterWithEmail(emailAddress); } EditorGUILayout.Separator(); GUILayout.Label("I am already signed up. Get me to setup."); if (GUILayout.Button("Setup")) photonSetupState = PhotonSetupStates._3a; EditorGUILayout.Separator(); } else if (photonSetupState == PhotonSetupStates._2) { GUI.skin.label.fontStyle = FontStyle.Bold; GUILayout.Label("Oops!"); GUI.skin.label.fontStyle = FontStyle.Normal; GUILayout.Label("The provided e-mail-address has already been registered."); if (GUILayout.Button("Mh, see my account page")) { Application.OpenURL(UrlAccountPage + emailAddress); } EditorGUILayout.Separator(); GUILayout.Label("Ah, I know my Application ID. Get me to setup."); GUILayout.BeginHorizontal(); if (GUILayout.Button("Cancel")) photonSetupState = PhotonSetupStates._1; if (GUILayout.Button("Setup")) photonSetupState = PhotonSetupStates._3a; GUILayout.EndHorizontal(); } else if (photonSetupState == PhotonSetupStates._3a) { // cloud setup GUI.skin.label.fontStyle = FontStyle.Bold; GUILayout.Label("Connect to Photon Cloud"); GUI.skin.label.fontStyle = FontStyle.Normal; EditorGUILayout.Separator(); this.SetupCloudAppIdGui(); this.CompareAndHelpOptionsGui(); } else if (photonSetupState == PhotonSetupStates._3b) { // self-hosting setup GUI.skin.label.fontStyle = FontStyle.Bold; GUILayout.Label("Setup own Photon Host"); GUI.skin.label.fontStyle = FontStyle.Normal; EditorGUILayout.Separator(); this.SetupSelfhostingGui(); this.CompareAndHelpOptionsGui(); } }
protected virtual void RegisterWithEmail(string email) { EditorUtility.DisplayProgressBar(CurrentLang.ConnectionTitle, CurrentLang.ConnectionInfo, 0.5f); string accountServiceType = string.Empty; #if PHOTON_VOICE accountServiceType = "voice"; #endif 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, 0); #if PHOTON_VOICE PhotonNetwork.PhotonServerSettings.VoiceAppID = client.AppId2; #endif PhotonEditor.SaveSettings(); this.photonSetupState = PhotonSetupStates.GoEditPhotonServerSettings; } else { PhotonNetwork.PhotonServerSettings.HostType = ServerSettings.HostingOption.PhotonCloud; 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; } } }
void RegisterWithEmail(string email) { EditorUtility.DisplayProgressBar("Connecting", "Connecting to the account service..", 0.5f); var client = new AccountService(UrlAccountService); Result defaultResult = new Result() { ReturnCode = -1, Message = "Account Service not available. Please use web-access and 'manual' setup." }; Result result = defaultResult; try { result = client.RegisterByEmail(email); } catch (Exception e) { Debug.LogError("Error trying to reach the cloud account service. Please use web-access." + e); } if (result == null) { result = defaultResult; } EditorUtility.ClearProgressBar(); if (result.ReturnCode == 0) { ServerSetting.UseCloud(result.Message); this.SavePhotonSettings(); this.ReloadHostingSettingsFromFile(); this.photonSetupState = PhotonSetupStates._3a; } else { if (result.Message.Contains("Email already registered")) this.photonSetupState = PhotonSetupStates._2; else EditorUtility.DisplayDialog("Error", result.Message, "OK"); } }
protected virtual void UiMainWizard() { GUILayout.Space(15); // title UiTitleBox(CurrentLang.PUNWizardLabel, BackgroundImage); // wizard info text GUILayout.Label(CurrentLang.WizardMainWindowInfo); GUILayout.Space(15); // pun+ info if (isPunPlus) { GUILayout.Label(CurrentLang.MobilePunPlusExportNoteLabel); GUILayout.Space(15); } #if !(UNITY_5_0 || UNITY_5) else if (!InternalEditorUtility.HasAdvancedLicenseOnBuildTarget(BuildTarget.Android) || !InternalEditorUtility.HasAdvancedLicenseOnBuildTarget(BuildTarget.iPhone)) { GUILayout.Label(CurrentLang.MobileExportNoteLabel); GUILayout.Space(15); } #endif // settings button GUILayout.BeginHorizontal(); GUILayout.Label(CurrentLang.SettingsButton, EditorStyles.boldLabel, GUILayout.Width(100)); GUILayout.BeginVertical(); if (GUILayout.Button(new GUIContent(CurrentLang.LocateSettingsButton, CurrentLang.SettingsHighlightLabel))) { HighlightSettings(); } if (GUILayout.Button(new GUIContent(CurrentLang.OpenCloudDashboardText, CurrentLang.OpenCloudDashboardTooltip))) { Application.OpenURL(UrlCloudDashboard + Uri.EscapeUriString(this.mailOrAppId)); } if (GUILayout.Button(new GUIContent(CurrentLang.SetupButton, CurrentLang.SetupServerCloudLabel))) { this.photonSetupState = PhotonSetupStates.RegisterForPhotonCloud; } GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.Space(15); // converter GUILayout.BeginHorizontal(); GUILayout.Label(CurrentLang.ConverterLabel, EditorStyles.boldLabel, GUILayout.Width(100)); if (GUILayout.Button(new GUIContent(CurrentLang.StartButton, CurrentLang.UNtoPUNLabel))) { PhotonConverter.RunConversion(); } GUILayout.EndHorizontal(); EditorGUILayout.Separator(); // documentation GUILayout.BeginHorizontal(); GUILayout.Label(CurrentLang.DocumentationLabel, EditorStyles.boldLabel, GUILayout.Width(100)); GUILayout.BeginVertical(); if (GUILayout.Button(new GUIContent(CurrentLang.OpenPDFText, CurrentLang.OpenPDFTooltip))) { EditorUtility.OpenWithDefaultApp(DocumentationLocation); } if (GUILayout.Button(new GUIContent(CurrentLang.OpenDevNetText, CurrentLang.OpenDevNetTooltip))) { Application.OpenURL(UrlDevNet); } GUI.skin.label.wordWrap = true; GUILayout.Label(CurrentLang.OwnHostCloudCompareLabel); if (GUILayout.Button(CurrentLang.ComparisonPageButton)) { Application.OpenURL(UrlCompare); } if (GUILayout.Button(new GUIContent(CurrentLang.OpenForumText, CurrentLang.OpenForumTooltip))) { Application.OpenURL(UrlForum); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); }
protected virtual void OnGuiSetupCloudAppId() { GUILayout.Label("Your APP ID:"); this.cloudAppId = EditorGUILayout.TextField(this.cloudAppId); GUILayout.BeginHorizontal(); if (GUILayout.Button("Cancel")) { GUIUtility.keyboardControl = 0; this.ReApplySettingsToWindow(); } int selectedRegion = ServerSettings.FindRegionForServerAddress(this.photonAddress); if (GUILayout.Button("Save")) { GUIUtility.keyboardControl = 0; this.cloudAppId = this.cloudAppId.Trim(); PhotonEditor.Current.UseCloud(this.cloudAppId, selectedRegion); PhotonEditor.Save(); EditorUtility.DisplayDialog("Success", "Saved your settings.", "ok"); } GUILayout.EndHorizontal(); EditorGUILayout.Separator(); GUILayout.BeginHorizontal(); GUILayout.Label("Cloud Region"); int toolbarValue = GUILayout.Toolbar(selectedRegion, ServerSettings.CloudServerRegionNames); if (selectedRegion != toolbarValue) { //Debug.Log("Replacing region: " + selectedRegion + " with: " + toolbarValue); this.photonAddress = ServerSettings.FindServerAddressForRegion(toolbarValue); } GUILayout.EndHorizontal(); EditorGUILayout.Separator(); GUILayout.Label("Running my app in the cloud was fun but...\nLet me setup my own Photon server."); if (GUILayout.Button("Switch to own host")) { this.photonAddress = ServerSettings.DefaultServerAddress; this.photonPort = ServerSettings.DefaultMasterPort; this.photonSetupState = PhotonSetupStates.SetupSelfHosted; } }
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 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.mailOrAppId = EditorGUILayout.TextField(this.mailOrAppId).Trim(); // note: we trim all input if (this.mailOrAppId.Contains("@")) { // this should be a mail address this.minimumInput = (this.mailOrAppId.Length >= 5 && this.mailOrAppId.Contains(".")); this.useMail = this.minimumInput; this.useAppId = false; } else { // this should be an appId this.minimumInput = ServerSettingsInspector.IsAppId(this.mailOrAppId); this.useMail = false; 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) { 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(UrlCloudDashboard + Uri.EscapeUriString(this.mailOrAppId)); this.mailOrAppId = ""; } 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; }
protected virtual void OnGuiSetupCloudAppId() { GUILayout.Label(CurrentLang.AppIdLabel); GUILayout.BeginHorizontal(); this.cloudAppId = EditorGUILayout.TextField(this.cloudAppId); open = GUILayout.Toggle(open, HelpIcon, GUIStyle.none, GUILayout.ExpandWidth(false)); GUILayout.EndHorizontal(); if (open) GUILayout.Label(CurrentLang.AppIdInfoLabel); EditorGUILayout.Separator(); GUILayout.Label(CurrentLang.CloudRegionLabel); int selectedRegion = ServerSettings.FindRegionForServerAddress(this.photonAddress); GUILayout.BeginHorizontal(); int toolbarValue = GUILayout.Toolbar(selectedRegion, cloudServerRegionNames); // the enum CloudServerRegion is converted into a string[] in init (toolbar can't use enum) helpRegion = GUILayout.Toggle(helpRegion, HelpIcon, GUIStyle.none, GUILayout.ExpandWidth(false)); GUILayout.EndHorizontal(); if (helpRegion) GUILayout.Label(CurrentLang.RegionalServersInfo); if (selectedRegion != toolbarValue) { //Debug.Log("Replacing region: " + selectedRegion + " with: " + toolbarValue); this.photonAddress = ServerSettings.FindServerAddressForRegion(toolbarValue); } EditorGUILayout.Separator(); GUILayout.BeginHorizontal(); if (GUILayout.Button(CurrentLang.CancelButton)) { GUIUtility.keyboardControl = 0; this.ReApplySettingsToWindow(); } if (GUILayout.Button(CurrentLang.SaveButton)) { GUIUtility.keyboardControl = 0; this.cloudAppId = this.cloudAppId.Trim(); PhotonEditor.Current.UseCloud(this.cloudAppId, selectedRegion); PhotonEditor.Save(); EditorUtility.DisplayDialog(CurrentLang.SettingsSavedTitle, CurrentLang.SettingsSavedMessage, CurrentLang.OkButton); } GUILayout.EndHorizontal(); GUILayout.Space(20); GUILayout.Label(CurrentLang.SetupOwnServerLabel); if (GUILayout.Button(CurrentLang.SelfHostSettingsButton)) { this.photonAddress = ServerSettings.DefaultServerAddress; this.photonPort = ServerSettings.DefaultMasterPort; this.photonSetupState = PhotonSetupStates.SetupSelfHosted; } EditorGUILayout.Separator(); GUILayout.Label(CurrentLang.OwnHostCloudCompareLabel); if (GUILayout.Button(CurrentLang.ComparisonPageButton)) { Application.OpenURL(UrlCompare); } }
protected virtual void OnGuiRegisterCloudApp() { GUI.skin.label.wordWrap = true; if (!this.isSetupWizard) { GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Close setup", GUILayout.ExpandWidth(false))) { this.SwitchMenuState(GUIState.Main); } GUILayout.EndHorizontal(); GUILayout.Space(15); } if (this.photonSetupState == PhotonSetupStates.RegisterForPhotonCloud) { GUI.skin.label.fontStyle = FontStyle.Bold; GUILayout.Label("Connect to Photon Cloud"); GUI.skin.label.fontStyle = FontStyle.Normal; GUILayout.Label("Your e-mail address is required to access your own free app."); this.emailAddress = EditorGUILayout.TextField("Email:", this.emailAddress); if (GUILayout.Button("Send")) { GUIUtility.keyboardControl = 0; this.RegisterWithEmail(this.emailAddress); } EditorGUILayout.Separator(); GUILayout.Label("I am already signed up. Let me enter my AppId."); if (GUILayout.Button("Setup")) { this.photonSetupState = PhotonSetupStates.SetupPhotonCloud; } GUILayout.Label("I want to register by a website."); if (GUILayout.Button("Open account website")) { EditorUtility.OpenWithDefaultApp(UrlAccountPage + Uri.EscapeUriString(this.emailAddress)); } EditorGUILayout.Separator(); } else if (this.photonSetupState == PhotonSetupStates.EmailAlreadyRegistered) { GUI.skin.label.fontStyle = FontStyle.Bold; GUILayout.Label("Oops!"); GUI.skin.label.fontStyle = FontStyle.Normal; GUILayout.Label("The provided e-mail-address has already been registered."); if (GUILayout.Button("Mh, see my account page")) { EditorUtility.OpenWithDefaultApp(UrlAccountPage + Uri.EscapeUriString(this.emailAddress)); } EditorGUILayout.Separator(); GUILayout.Label("Ah, I know my Application ID. Get me to setup."); GUILayout.BeginHorizontal(); if (GUILayout.Button("Cancel")) { this.photonSetupState = PhotonSetupStates.RegisterForPhotonCloud; } if (GUILayout.Button("Setup")) { this.photonSetupState = PhotonSetupStates.SetupPhotonCloud; } GUILayout.EndHorizontal(); } else if (this.photonSetupState == PhotonSetupStates.SetupPhotonCloud) { // cloud setup GUI.skin.label.fontStyle = FontStyle.Bold; GUILayout.Label("Connect to Photon Cloud"); GUI.skin.label.fontStyle = FontStyle.Normal; EditorGUILayout.Separator(); this.OnGuiSetupCloudAppId(); this.OnGuiCompareAndHelpOptions(); } else if (this.photonSetupState == PhotonSetupStates.SetupSelfHosted) { // self-hosting setup GUI.skin.label.fontStyle = FontStyle.Bold; GUILayout.Label("Setup own Photon Host"); GUI.skin.label.fontStyle = FontStyle.Normal; EditorGUILayout.Separator(); this.OnGuiSetupSelfhosting(); this.OnGuiCompareAndHelpOptions(); } }
protected virtual void OnGuiRegisterCloudApp() { GUI.skin.label.wordWrap = true; if (!this.isSetupWizard) { GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button(CurrentLang.MainMenuButton, GUILayout.ExpandWidth(false))) { this.SwitchMenuState(GUIState.Main); } GUILayout.EndHorizontal(); GUILayout.Space(15); } if (this.photonSetupState == PhotonSetupStates.RegisterForPhotonCloud) { GUI.skin.label.fontStyle = FontStyle.Bold; GUILayout.Label(CurrentLang.ConnectButton); EditorGUILayout.Separator(); GUI.skin.label.fontStyle = FontStyle.Normal; GUILayout.Label(CurrentLang.UsePhotonLabel); EditorGUILayout.Separator(); this.emailAddress = EditorGUILayout.TextField(CurrentLang.EmailLabel, this.emailAddress); if (GUILayout.Button(CurrentLang.SendButton)) { GUIUtility.keyboardControl = 0; this.RegisterWithEmail(this.emailAddress); } GUILayout.Space(20); GUILayout.Label(CurrentLang.SignedUpAlreadyLabel); if (GUILayout.Button(CurrentLang.SetupButton)) { this.photonSetupState = PhotonSetupStates.SetupPhotonCloud; } EditorGUILayout.Separator(); GUILayout.Label(CurrentLang.RegisterByWebsiteLabel); if (GUILayout.Button(CurrentLang.AccountWebsiteButton)) { EditorUtility.OpenWithDefaultApp(UrlAccountPage + Uri.EscapeUriString(this.emailAddress)); } EditorGUILayout.Separator(); GUILayout.Label(CurrentLang.SelfHostLabel); if (GUILayout.Button(CurrentLang.SelfHostSettingsButton)) { this.photonSetupState = PhotonSetupStates.SetupSelfHosted; } GUILayout.FlexibleSpace(); if (!InternalEditorUtility.HasAdvancedLicenseOnBuildTarget(BuildTarget.Android) || !InternalEditorUtility.HasAdvancedLicenseOnBuildTarget(BuildTarget.iPhone)) { GUILayout.Label(CurrentLang.MobileExportNoteLabel); } EditorGUILayout.Separator(); } else if (this.photonSetupState == PhotonSetupStates.EmailAlreadyRegistered) { GUI.skin.label.fontStyle = FontStyle.Bold; GUILayout.Label(CurrentLang.OopsLabel); GUI.skin.label.fontStyle = FontStyle.Normal; GUILayout.Label(CurrentLang.EmailInUseLabel); if (GUILayout.Button(CurrentLang.SeeMyAccountPageButton)) { EditorUtility.OpenWithDefaultApp(UrlCloudDashboard + Uri.EscapeUriString(this.emailAddress)); } EditorGUILayout.Separator(); GUILayout.Label(CurrentLang.KnownAppIdLabel); GUILayout.BeginHorizontal(); if (GUILayout.Button(CurrentLang.CancelButton)) { this.photonSetupState = PhotonSetupStates.RegisterForPhotonCloud; } if (GUILayout.Button(CurrentLang.SetupButton)) { this.photonSetupState = PhotonSetupStates.SetupPhotonCloud; } GUILayout.EndHorizontal(); } else if (this.photonSetupState == PhotonSetupStates.SetupPhotonCloud) { // cloud setup GUI.skin.label.fontStyle = FontStyle.Bold; GUILayout.Label(CurrentLang.PhotonCloudConnect); GUI.skin.label.fontStyle = FontStyle.Normal; EditorGUILayout.Separator(); this.OnGuiSetupCloudAppId(); this.OnGuiCompareAndHelpOptions(); } else if (this.photonSetupState == PhotonSetupStates.SetupSelfHosted) { // self-hosting setup GUI.skin.label.fontStyle = FontStyle.Bold; GUILayout.Label(CurrentLang.SetupOwnHostLabel); GUI.skin.label.fontStyle = FontStyle.Normal; EditorGUILayout.Separator(); this.OnGuiSetupSelfhosting(); this.OnGuiCompareAndHelpOptions(); } }
protected virtual void OnGuiRegisterCloudApp() { GUI.skin.label.wordWrap = true; if (!this.isSetupWizard) { GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button(CurrentLang.MainMenuButton, GUILayout.ExpandWidth(false))) { this.SwitchMenuState(GUIState.Main); } GUILayout.EndHorizontal(); GUILayout.Space(15); } if (this.photonSetupState == PhotonSetupStates.RegisterForPhotonCloud) { GUI.skin.label.fontStyle = FontStyle.Bold; GUILayout.Label(CurrentLang.ConnectButton); EditorGUILayout.Separator(); GUI.skin.label.fontStyle = FontStyle.Normal; GUILayout.Label(CurrentLang.UsePhotonLabel); EditorGUILayout.Separator(); this.emailAddress = EditorGUILayout.TextField(CurrentLang.EmailLabel, this.emailAddress); if (GUILayout.Button(CurrentLang.SendButton)) { GUIUtility.keyboardControl = 0; this.RegisterWithEmail(this.emailAddress); } GUILayout.Space(20); GUILayout.Label(CurrentLang.SignedUpAlreadyLabel); if (GUILayout.Button(CurrentLang.SetupButton)) { this.photonSetupState = PhotonSetupStates.SetupPhotonCloud; } EditorGUILayout.Separator(); GUILayout.Label(CurrentLang.RegisterByWebsiteLabel); if (GUILayout.Button(CurrentLang.AccountWebsiteButton)) { EditorUtility.OpenWithDefaultApp(UrlAccountPage + Uri.EscapeUriString(this.emailAddress)); } EditorGUILayout.Separator(); GUILayout.Label(CurrentLang.SelfHostLabel); if (GUILayout.Button(CurrentLang.SelfHostSettingsButton)) { this.photonSetupState = PhotonSetupStates.SetupSelfHosted; } GUILayout.FlexibleSpace(); if (!InternalEditorUtility.HasAdvancedLicenseOnBuildTarget(BuildTarget.Android) || !InternalEditorUtility.HasAdvancedLicenseOnBuildTarget(BuildTarget.iOS)) { GUILayout.Label(CurrentLang.MobileExportNoteLabel); } EditorGUILayout.Separator(); } else if (this.photonSetupState == PhotonSetupStates.EmailAlreadyRegistered) { GUI.skin.label.fontStyle = FontStyle.Bold; GUILayout.Label(CurrentLang.OopsLabel); GUI.skin.label.fontStyle = FontStyle.Normal; GUILayout.Label(CurrentLang.EmailInUseLabel); if (GUILayout.Button(CurrentLang.SeeMyAccountPageButton)) { EditorUtility.OpenWithDefaultApp(UrlCloudDashboard + Uri.EscapeUriString(this.emailAddress)); } EditorGUILayout.Separator(); GUILayout.Label(CurrentLang.KnownAppIdLabel); GUILayout.BeginHorizontal(); if (GUILayout.Button(CurrentLang.CancelButton)) { this.photonSetupState = PhotonSetupStates.RegisterForPhotonCloud; } if (GUILayout.Button(CurrentLang.SetupButton)) { this.photonSetupState = PhotonSetupStates.SetupPhotonCloud; } GUILayout.EndHorizontal(); } else if (this.photonSetupState == PhotonSetupStates.SetupPhotonCloud) { // cloud setup GUI.skin.label.fontStyle = FontStyle.Bold; GUILayout.Label(CurrentLang.PhotonCloudConnect); GUI.skin.label.fontStyle = FontStyle.Normal; EditorGUILayout.Separator(); this.OnGuiSetupCloudAppId(); this.OnGuiCompareAndHelpOptions(); } else if (this.photonSetupState == PhotonSetupStates.SetupSelfHosted) { // self-hosting setup GUI.skin.label.fontStyle = FontStyle.Bold; GUILayout.Label(CurrentLang.SetupOwnHostLabel); GUI.skin.label.fontStyle = FontStyle.Normal; EditorGUILayout.Separator(); this.OnGuiSetupSelfhosting(); this.OnGuiCompareAndHelpOptions(); } }
protected virtual void OnGuiSetupSelfhosting() { GUILayout.Label(CurrentLang.YourPhotonServerLabel); this.photonAddress = EditorGUILayout.TextField(CurrentLang.AddressIPLabel, this.photonAddress); this.photonPort = EditorGUILayout.IntField(CurrentLang.PortLabel, this.photonPort); this.photonProtocol = (ConnectionProtocol)EditorGUILayout.EnumPopup("Protocol", this.photonProtocol); EditorGUILayout.Separator(); GUILayout.BeginHorizontal(); if (GUILayout.Button(CurrentLang.CancelButton)) { GUIUtility.keyboardControl = 0; this.ReApplySettingsToWindow(); } if (GUILayout.Button(CurrentLang.SaveButton)) { GUIUtility.keyboardControl = 0; PhotonEditor.Current.UseMyServer(this.photonAddress, this.photonPort, null); PhotonEditor.Current.Protocol = this.photonProtocol; PhotonEditor.Save(); Inspect(); EditorUtility.DisplayDialog(CurrentLang.SettingsSavedTitle, CurrentLang.SettingsSavedMessage, CurrentLang.OkButton); } GUILayout.EndHorizontal(); GUILayout.Space(20); // license GUILayout.BeginHorizontal(); GUILayout.Label(CurrentLang.LicensesLabel, EditorStyles.boldLabel, GUILayout.Width(100)); if (GUILayout.Button(new GUIContent(CurrentLang.LicenseDownloadText, CurrentLang.LicenseDownloadTooltip))) { EditorUtility.OpenWithDefaultApp(UrlFreeLicense); } GUILayout.EndHorizontal(); GUILayout.Space(20); GUILayout.Label(CurrentLang.TryPhotonAppLabel); if (GUILayout.Button(CurrentLang.GetCloudAppButton)) { this.cloudAppId = string.Empty; this.photonSetupState = PhotonSetupStates.RegisterForPhotonCloud; } EditorGUILayout.Separator(); GUILayout.Label(CurrentLang.OwnHostCloudCompareLabel); if (GUILayout.Button(CurrentLang.ComparisonPageButton)) { Application.OpenURL(UrlCompare); } }
protected virtual void OnGuiSetupCloudAppId() { GUILayout.Label(CurrentLang.AppIdLabel); GUILayout.BeginHorizontal(); this.cloudAppId = EditorGUILayout.TextField(this.cloudAppId); open = GUILayout.Toggle(open, HelpIcon, GUIStyle.none, GUILayout.ExpandWidth(false)); GUILayout.EndHorizontal(); if (open) { GUILayout.Label(CurrentLang.AppIdInfoLabel); } EditorGUILayout.Separator(); GUILayout.Label(CurrentLang.CloudRegionLabel); GUILayout.BeginHorizontal(); int toolbarValue = GUILayout.Toolbar((int)selectedRegion, CloudServerRegionNames); // the enum CloudRegionCode is converted into a string[] in init (toolbar can't use enum) helpRegion = GUILayout.Toggle(helpRegion, HelpIcon, GUIStyle.none, GUILayout.ExpandWidth(false)); GUILayout.EndHorizontal(); if (helpRegion) { GUILayout.Label(CurrentLang.RegionalServersInfo); } PhotonEditor.selectedRegion = (CloudRegionCode)toolbarValue; EditorGUILayout.Separator(); GUILayout.BeginHorizontal(); if (GUILayout.Button(CurrentLang.CancelButton)) { GUIUtility.keyboardControl = 0; this.ReApplySettingsToWindow(); } if (GUILayout.Button(CurrentLang.SaveButton)) { GUIUtility.keyboardControl = 0; this.cloudAppId = this.cloudAppId.Trim(); PhotonEditor.Current.UseCloud(this.cloudAppId); PhotonEditor.Current.PreferredRegion = PhotonEditor.selectedRegion; PhotonEditor.Current.HostType = (PhotonEditor.Current.PreferredRegion == CloudRegionCode.none) ? ServerSettings.HostingOption.BestRegion : ServerSettings.HostingOption.PhotonCloud; PhotonEditor.Save(); Inspect(); EditorUtility.DisplayDialog(CurrentLang.SettingsSavedTitle, CurrentLang.SettingsSavedMessage, CurrentLang.OkButton); } GUILayout.EndHorizontal(); GUILayout.Space(20); GUILayout.Label(CurrentLang.SetupOwnServerLabel); if (GUILayout.Button(CurrentLang.SelfHostSettingsButton)) { //this.photonAddress = ServerSettings.DefaultServerAddress; //this.photonPort = ServerSettings.DefaultMasterPort; this.photonSetupState = PhotonSetupStates.SetupSelfHosted; } EditorGUILayout.Separator(); GUILayout.Label(CurrentLang.OwnHostCloudCompareLabel); if (GUILayout.Button(CurrentLang.ComparisonPageButton)) { Application.OpenURL(UrlCompare); } }
protected virtual void RegisterWithEmail(string email) { EditorUtility.DisplayProgressBar(CurrentLang.ConnectionTitle, CurrentLang.ConnectionInfo, 0.5f); var client = new AccountService(); client.RegisterByEmail(email, RegisterOrigin); // this is the synchronous variant using the static RegisterOrigin. "result" is in the client EditorUtility.ClearProgressBar(); if (client.ReturnCode == 0) { PhotonNetwork.PhotonServerSettings.UseCloud(client.AppId, 0); PhotonEditor.Save(); this.mailOrAppId = client.AppId; this.photonSetupState = PhotonSetupStates.GoEditPhotonServerSettings; } else { Debug.LogWarning(client.Message); if (client.Message.Contains("registered")) { PhotonNetwork.PhotonServerSettings.UseCloud(""); PhotonEditor.Save(); this.photonSetupState = PhotonSetupStates.EmailAlreadyRegistered; } else { EditorUtility.DisplayDialog(CurrentLang.ErrorTextTitle, client.Message, CurrentLang.OkButton); PhotonNetwork.PhotonServerSettings.UseCloud(""); PhotonEditor.Save(); this.photonSetupState = PhotonSetupStates.RegisterForPhotonCloud; } } }
void SetupGUI() { GUI.skin.label.wordWrap = true; if (!isSetupWizard) { GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Close setup", GUILayout.ExpandWidth(false))) { SwitchMenuState(GUIState.Main); } GUILayout.EndHorizontal(); GUILayout.Space(15); } if (photonSetupState == PhotonSetupStates._1) { GUI.skin.label.fontStyle = FontStyle.Bold; GUILayout.Label("Connect to Photon Cloud"); GUI.skin.label.fontStyle = FontStyle.Normal; GUILayout.Label("Your e-mail address is required to access your own free app."); emailAddress = EditorGUILayout.TextField("Email:", emailAddress); if (GUILayout.Button("Send")) { GUIUtility.keyboardControl = 0; RegisterWithEmail(emailAddress); } EditorGUILayout.Separator(); GUILayout.Label("I am already signed up. Get me to setup."); if (GUILayout.Button("Setup")) { photonSetupState = PhotonSetupStates._3a; } EditorGUILayout.Separator(); } else if (photonSetupState == PhotonSetupStates._2) { GUI.skin.label.fontStyle = FontStyle.Bold; GUILayout.Label("Oops!"); GUI.skin.label.fontStyle = FontStyle.Normal; GUILayout.Label("The provided e-mail-address has already been registered."); if (GUILayout.Button("Mh, see my account page")) { Application.OpenURL(UrlAccountPage + emailAddress); } EditorGUILayout.Separator(); GUILayout.Label("Ah, I know my Application ID. Get me to setup."); GUILayout.BeginHorizontal(); if (GUILayout.Button("Cancel")) { photonSetupState = PhotonSetupStates._1; } if (GUILayout.Button("Setup")) { photonSetupState = PhotonSetupStates._3a; } GUILayout.EndHorizontal(); } else if (photonSetupState == PhotonSetupStates._3a) { // cloud setup GUI.skin.label.fontStyle = FontStyle.Bold; GUILayout.Label("Connect to Photon Cloud"); GUI.skin.label.fontStyle = FontStyle.Normal; EditorGUILayout.Separator(); this.SetupCloudAppIdGui(); this.CompareAndHelpOptionsGui(); } else if (photonSetupState == PhotonSetupStates._3b) { // self-hosting setup GUI.skin.label.fontStyle = FontStyle.Bold; GUILayout.Label("Setup own Photon Host"); GUI.skin.label.fontStyle = FontStyle.Normal; EditorGUILayout.Separator(); this.SetupSelfhostingGui(); this.CompareAndHelpOptionsGui(); } }
protected virtual void UiMainWizard() { GUILayout.Space(15); // title this.UiTitleBox(CurrentLang.PUNWizardLabel, BackgroundImage); EditorGUILayout.BeginVertical(new GUIStyle() { padding = new RectOffset(10, 10, 10, 10) }); // wizard info text GUILayout.Label(CurrentLang.WizardMainWindowInfo, new GUIStyle("Label") { wordWrap = true }); GUILayout.Space(15); // settings button GUILayout.Label(CurrentLang.SettingsButton, EditorStyles.boldLabel); if (GUILayout.Button(new GUIContent(CurrentLang.LocateSettingsButton, CurrentLang.SettingsHighlightLabel))) { HighlightSettings(); } if (GUILayout.Button(new GUIContent(CurrentLang.OpenCloudDashboardText, CurrentLang.OpenCloudDashboardTooltip))) { Application.OpenURL(UrlCloudDashboard + Uri.EscapeUriString(this.mailOrAppId)); } if (GUILayout.Button(new GUIContent(CurrentLang.SetupButton, CurrentLang.SetupServerCloudLabel))) { this.photonSetupState = PhotonSetupStates.RegisterForPhotonCloud; } GUILayout.Space(15); // documentation GUILayout.Label(CurrentLang.DocumentationLabel, EditorStyles.boldLabel); if (GUILayout.Button(new GUIContent(CurrentLang.OpenPDFText, CurrentLang.OpenPDFTooltip))) { EditorUtility.OpenWithDefaultApp(DocumentationLocation); } if (GUILayout.Button(new GUIContent(CurrentLang.OpenDevNetText, CurrentLang.OpenDevNetTooltip))) { Application.OpenURL(UrlDevNet); } GUI.skin.label.wordWrap = true; GUILayout.Label(CurrentLang.OwnHostCloudCompareLabel); if (GUILayout.Button(CurrentLang.ComparisonPageButton)) { Application.OpenURL(UrlCompare); } if (GUILayout.Button(new GUIContent(CurrentLang.OpenForumText, CurrentLang.OpenForumTooltip))) { Application.OpenURL(UrlForum); } GUILayout.EndVertical(); }
/// <summary>Re-initializes the Photon Setup window and shows one of three states: register cloud, setup cloud, setup self-hosted.</summary> protected void InitPhotonSetupWindow() { this.minSize = this.preferredSize; this.SwitchMenuState(GUIState.Setup); switch (PhotonNetwork.PhotonServerSettings.HostType) { case ServerSettings.HostingOption.PhotonCloud: case ServerSettings.HostingOption.BestRegion: default: this.photonSetupState = PhotonSetupStates.RegisterForPhotonCloud; break; } }
protected virtual void OnGuiRegisterCloudApp() { GUI.skin.label.wordWrap = true; if (!this.isSetupWizard) { GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Main Menu", GUILayout.ExpandWidth(false))) { this.SwitchMenuState(GUIState.Main); } GUILayout.EndHorizontal(); GUILayout.Space(15); } if (this.photonSetupState == PhotonSetupStates.RegisterForPhotonCloud) { GUI.skin.label.fontStyle = FontStyle.Bold; GUILayout.Label("Connect to Photon Cloud"); EditorGUILayout.Separator(); GUI.skin.label.fontStyle = FontStyle.Normal; GUILayout.Label("Using the Photon Cloud is free for development. If you don't have an account yet, enter your email and register."); EditorGUILayout.Separator(); this.emailAddress = EditorGUILayout.TextField("Email:", this.emailAddress); if (GUILayout.Button("Send")) { GUIUtility.keyboardControl = 0; this.RegisterWithEmail(this.emailAddress); } GUILayout.Space(20); GUILayout.Label("I am already signed up. Let me enter my AppId."); if (GUILayout.Button("Setup")) { this.photonSetupState = PhotonSetupStates.SetupPhotonCloud; } EditorGUILayout.Separator(); GUILayout.Label("I want to register by a website."); if (GUILayout.Button("Open account website")) { EditorUtility.OpenWithDefaultApp(UrlAccountPage + Uri.EscapeUriString(this.emailAddress)); } EditorGUILayout.Separator(); GUILayout.Label("I want to host my own server. Let me set it up."); if (GUILayout.Button("Open self-hosting settings")) { this.photonAddress = ServerSettings.DefaultServerAddress; this.photonPort = ServerSettings.DefaultMasterPort; this.photonSetupState = PhotonSetupStates.SetupSelfHosted; } GUILayout.FlexibleSpace(); if (!InternalEditorUtility.HasAdvancedLicenseOnBuildTarget(BuildTarget.Android) || !InternalEditorUtility.HasAdvancedLicenseOnBuildTarget(BuildTarget.iPhone)) { GUILayout.Label("Note: Export to mobile will require iOS Pro / Android Pro."); } EditorGUILayout.Separator(); } else if (this.photonSetupState == PhotonSetupStates.EmailAlreadyRegistered) { GUI.skin.label.fontStyle = FontStyle.Bold; GUILayout.Label("Oops!"); GUI.skin.label.fontStyle = FontStyle.Normal; GUILayout.Label("The provided e-mail-address has already been registered."); if (GUILayout.Button("Mh, see my account page")) { EditorUtility.OpenWithDefaultApp(UrlCloudDashboard + Uri.EscapeUriString(this.emailAddress)); } EditorGUILayout.Separator(); GUILayout.Label("Ah, I know my Application ID. Get me to setup."); GUILayout.BeginHorizontal(); if (GUILayout.Button("Cancel")) { this.photonSetupState = PhotonSetupStates.RegisterForPhotonCloud; } if (GUILayout.Button("Setup")) { this.photonSetupState = PhotonSetupStates.SetupPhotonCloud; } GUILayout.EndHorizontal(); } else if (this.photonSetupState == PhotonSetupStates.SetupPhotonCloud) { // cloud setup GUI.skin.label.fontStyle = FontStyle.Bold; GUILayout.Label("Connect to Photon Cloud"); GUI.skin.label.fontStyle = FontStyle.Normal; EditorGUILayout.Separator(); this.OnGuiSetupCloudAppId(); this.OnGuiCompareAndHelpOptions(); } else if (this.photonSetupState == PhotonSetupStates.SetupSelfHosted) { // self-hosting setup GUI.skin.label.fontStyle = FontStyle.Bold; GUILayout.Label("Setup own Photon Host"); GUI.skin.label.fontStyle = FontStyle.Normal; EditorGUILayout.Separator(); this.OnGuiSetupSelfhosting(); this.OnGuiCompareAndHelpOptions(); } }
//3a void SetupCloudAppIdGui() { GUILayout.Label("Your APP ID:"); cloudAPPID = EditorGUILayout.TextField(cloudAPPID); GUILayout.BeginHorizontal(); if (GUILayout.Button("Cancel")) { GUIUtility.keyboardControl = 0; this.ReloadHostingSettingsFromFile(); } if (GUILayout.Button("Save")) { GUIUtility.keyboardControl = 0; ServerSetting.UseCloud(this.cloudAPPID); this.SavePhotonSettings(); EditorUtility.DisplayDialog("Success", "Saved your settings.", "ok"); } GUILayout.EndHorizontal(); EditorGUILayout.Separator(); GUILayout.Label("Running my app in the cloud was fun but...\nLet me setup my own Photon server."); if (GUILayout.Button("Switch to own host")) { this.photonIP = ServerSettings.DefaultServerAddress; this.photonPort = ServerSettings.DefaultMasterPort; photonSetupState = PhotonSetupStates._3b; } }
protected virtual void OnGuiRegisterCloudApp() { GUI.skin.label.wordWrap = true; if (!this.isSetupWizard) { GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button(CurrentLang.MainMenuButton, GUILayout.ExpandWidth(false))) { this.SwitchMenuState(GUIState.Main); } GUILayout.EndHorizontal(); } GUILayout.Space(15); GUI.skin.label.fontStyle = FontStyle.Bold; GUILayout.Label(CurrentLang.SetupWizardTitle); EditorGUILayout.Separator(); GUI.skin.label.fontStyle = FontStyle.Normal; GUI.skin.label.richText = true; GUILayout.Label(CurrentLang.SetupWizardInfo); EditorGUILayout.Separator(); GUILayout.Label(CurrentLang.EmailOrAppIdLabel); this.mailOrAppId = EditorGUILayout.TextField(this.mailOrAppId).Trim(); // note: we trim all input if (mailOrAppId.Contains("@")) { // this should be a mail address this.minimumInput = (mailOrAppId.Length >= 5 && mailOrAppId.Contains(".")); this.useMail = minimumInput; this.useAppId = false; } else { // this should be an appId this.minimumInput = ServerSettingsInspector.IsAppId(mailOrAppId); this.useMail = false; this.useAppId = minimumInput; } 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(!minimumInput); if (GUILayout.Button(CurrentLang.SetupButton, GUILayout.Width(100))) { this.useSkip = false; GUIUtility.keyboardControl = 0; if (useMail) { this.RegisterWithEmail(this.mailOrAppId); // sets state } if (useAppId) { this.photonSetupState = PhotonSetupStates.GoEditPhotonServerSettings; PhotonNetwork.PhotonServerSettings.UseCloud(this.mailOrAppId); PhotonEditor.Save(); } } 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("The email is registered so we can't fetch your AppId (without password).\n\nPlease login online to get your AppId."); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button(new GUIContent(CurrentLang.OpenCloudDashboardText, CurrentLang.OpenCloudDashboardTooltip), GUILayout.Width(205))) { EditorUtility.OpenWithDefaultApp(UrlCloudDashboard + Uri.EscapeUriString(this.mailOrAppId)); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } if (this.photonSetupState == PhotonSetupStates.GoEditPhotonServerSettings) { if (!highlightedSettings) { highlightedSettings = true; HighlightSettings(); } GUILayout.Space(15); if (useSkip) { GUILayout.Label("Skipping? No problem:\nEdit your server settings in the PhotonServerSettings file."); } else if (useMail) { GUILayout.Label("We created a (free) account and fetched you an AppId.\nWelcome. Your PUN project is setup."); } else if (useAppId) { GUILayout.Label("Your AppId is now applied to this project."); } GUILayout.Space(15); GUILayout.Label("<b>Done!</b>\nAll connection settings can be edited in the <b>PhotonServerSettings</b> now.\nHave a look."); // find / select settings asset GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Close", GUILayout.Width(205))) { this.close = true; } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } GUI.skin.label.richText = false; }
protected virtual void OnGuiSetupCloudAppId() { GUILayout.Label("Your AppId"); GUILayout.BeginHorizontal(); this.cloudAppId = EditorGUILayout.TextField(this.cloudAppId); open = GUILayout.Toggle(open, HelpIcon, GUIStyle.none, GUILayout.ExpandWidth(false)); GUILayout.EndHorizontal(); if (open) GUILayout.Label("The AppId a Guid that identifies your game in the Photon Cloud. Find it on your dashboard page."); EditorGUILayout.Separator(); GUILayout.Label("Cloud Region"); int selectedRegion = ServerSettings.FindRegionForServerAddress(this.photonAddress); GUILayout.BeginHorizontal(); int toolbarValue = GUILayout.Toolbar(selectedRegion, ServerSettings.CloudServerRegionNames); helpRegion = GUILayout.Toggle(helpRegion, HelpIcon, GUIStyle.none, GUILayout.ExpandWidth(false)); GUILayout.EndHorizontal(); if (helpRegion) GUILayout.Label("Photon Cloud has regional servers. Picking one near your customers improves ping times. You could use more than one but this setup does not support it."); if (selectedRegion != toolbarValue) { //Debug.Log("Replacing region: " + selectedRegion + " with: " + toolbarValue); this.photonAddress = ServerSettings.FindServerAddressForRegion(toolbarValue); } EditorGUILayout.Separator(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Cancel")) { GUIUtility.keyboardControl = 0; this.ReApplySettingsToWindow(); } if (GUILayout.Button("Save")) { GUIUtility.keyboardControl = 0; this.cloudAppId = this.cloudAppId.Trim(); PhotonEditor.Current.UseCloud(this.cloudAppId, selectedRegion); PhotonEditor.Save(); EditorUtility.DisplayDialog("Success", "Saved your settings.", "ok"); } GUILayout.EndHorizontal(); GUILayout.Space(20); GUILayout.Label("Running my app in the cloud was fun but...\nLet me setup my own Photon server."); if (GUILayout.Button("Open self-hosting settings")) { this.photonAddress = ServerSettings.DefaultServerAddress; this.photonPort = ServerSettings.DefaultMasterPort; this.photonSetupState = PhotonSetupStates.SetupSelfHosted; } EditorGUILayout.Separator(); GUILayout.Label("I am not quite sure how 'my own host' compares to 'cloud'."); if (GUILayout.Button("See comparison page")) { Application.OpenURL(UrlCompare); } }
protected virtual void RegisterWithEmail(string email) { EditorUtility.DisplayProgressBar("Connecting", "Connecting to the account service..", 0.5f); var client = new AccountService(); client.RegisterByEmail(email, RegisterOrigin); // this is the synchronous variant using the static RegisterOrigin. "result" is in the client EditorUtility.ClearProgressBar(); if (client.ReturnCode == 0) { PhotonEditor.Current.UseCloud(client.AppId); PhotonEditor.Save(); this.ReApplySettingsToWindow(); this.photonSetupState = PhotonSetupStates.SetupPhotonCloud; } else { if (client.Message.Contains("Email already registered")) { this.photonSetupState = PhotonSetupStates.EmailAlreadyRegistered; } else { EditorUtility.DisplayDialog("Error", client.Message, "OK"); // Debug.Log(client.Exception); this.photonSetupState = PhotonSetupStates.RegisterForPhotonCloud; } } }
// SETUP GUI void OpenSetup() { SwitchMenuState(GUIState.Setup); this.ReloadHostingSettingsFromFile(); switch (ServerSetting.HostType) { case ServerSettings.HostingOption.PhotonCloud: photonSetupState = PhotonSetupStates._3a; break; case ServerSettings.HostingOption.SelfHosted: photonSetupState = PhotonSetupStates._3b; break; case ServerSettings.HostingOption.NotSet: default: photonSetupState = PhotonSetupStates._1; break; } }