SetupSelfHosted
How do I use Setup Self Hosted
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
File name: PhotonEditor.cs
Copy
147 {
148 RegisterForPhotonCloud,
149
150 EmailAlreadyRegistered,
151
152 SetupPhotonCloud,
153
154 SetupSelfHosted
155 }
File name: PhotonEditor.cs
Copy
294 protected void InitPhotonSetupWindow()
295 {
296 this.minSize = MinSize;
297
298 this.SwitchMenuState(GUIState.Setup);
299 this.ReApplySettingsToWindow();
300
301 switch (PhotonEditor.Current.HostType)
302 {
303 case ServerSettings.HostingOption.PhotonCloud:
304 case ServerSettings.HostingOption.BestRegion:
305 this.photonSetupState = PhotonSetupStates.SetupPhotonCloud;
306 break;
307 case ServerSettings.HostingOption.SelfHosted:
308 this.photonSetupState = PhotonSetupStates.SetupSelfHosted;
309 break;
310 case ServerSettings.HostingOption.NotSet:
311 default:
312 this.photonSetupState = PhotonSetupStates.RegisterForPhotonCloud;
313 break;
314 }
315 }
File name: PhotonEditor.cs
Copy
420 protected virtual void OnGuiRegisterCloudApp()
421 {
422 GUI.skin.label.wordWrap = true;
423 if (!this.isSetupWizard)
424 {
425 GUILayout.BeginHorizontal();
426 GUILayout.FlexibleSpace();
427 if (GUILayout.Button(CurrentLang.MainMenuButton, GUILayout.ExpandWidth(false)))
428 {
429 this.SwitchMenuState(GUIState.Main);
430 }
431
432 GUILayout.EndHorizontal();
433
434 GUILayout.Space(15);
435 }
436
437 if (this.photonSetupState == PhotonSetupStates.RegisterForPhotonCloud)
438 {
439 GUI.skin.label.fontStyle = FontStyle.Bold;
440 GUILayout.Label(CurrentLang.ConnectButton);
441 EditorGUILayout.Separator();
442 GUI.skin.label.fontStyle = FontStyle.Normal;
443
444 GUILayout.Label(CurrentLang.UsePhotonLabel);
445 EditorGUILayout.Separator();
446 this.emailAddress = EditorGUILayout.TextField(CurrentLang.EmailLabel, this.emailAddress);
447
448 if (GUILayout.Button(CurrentLang.SendButton))
449 {
450 GUIUtility.keyboardControl = 0;
451 this.RegisterWithEmail(this.emailAddress);
452 }
453
454 GUILayout.Space(20);
455
456
457 GUILayout.Label(CurrentLang.SignedUpAlreadyLabel);
458 if (GUILayout.Button(CurrentLang.SetupButton))
459 {
460 this.photonSetupState = PhotonSetupStates.SetupPhotonCloud;
461 }
462 EditorGUILayout.Separator();
463
464
465 GUILayout.Label(CurrentLang.RegisterByWebsiteLabel);
466 if (GUILayout.Button(CurrentLang.AccountWebsiteButton))
467 {
468 EditorUtility.OpenWithDefaultApp(UrlAccountPage + Uri.EscapeUriString(this.emailAddress));
469 }
470
471 EditorGUILayout.Separator();
472
473 GUILayout.Label(CurrentLang.SelfHostLabel);
474
475 if (GUILayout.Button(CurrentLang.SelfHostSettingsButton))
476 {
477 this.photonSetupState = PhotonSetupStates.SetupSelfHosted;
478 }
479
480 GUILayout.FlexibleSpace();
481
482
483 if (!InternalEditorUtility.HasAdvancedLicenseOnBuildTarget(BuildTarget.Android) || !InternalEditorUtility.HasAdvancedLicenseOnBuildTarget(BuildTarget.iOS))
484 {
485 GUILayout.Label(CurrentLang.MobileExportNoteLabel);
486 }
487 EditorGUILayout.Separator();
488 }
489 else if (this.photonSetupState == PhotonSetupStates.EmailAlreadyRegistered)
490 {
491 GUI.skin.label.fontStyle = FontStyle.Bold;
492 GUILayout.Label(CurrentLang.OopsLabel);
493 GUI.skin.label.fontStyle = FontStyle.Normal;
494
495 GUILayout.Label(CurrentLang.EmailInUseLabel);
496
497 if (GUILayout.Button(CurrentLang.SeeMyAccountPageButton))
498 {
499 EditorUtility.OpenWithDefaultApp(UrlCloudDashboard + Uri.EscapeUriString(this.emailAddress));
500 }
501
502 EditorGUILayout.Separator();
503
504 GUILayout.Label(CurrentLang.KnownAppIdLabel);
505 GUILayout.BeginHorizontal();
506 if (GUILayout.Button(CurrentLang.CancelButton))
507 {
508 this.photonSetupState = PhotonSetupStates.RegisterForPhotonCloud;
509 }
510
511 if (GUILayout.Button(CurrentLang.SetupButton))
512 {
513 this.photonSetupState = PhotonSetupStates.SetupPhotonCloud;
514 }
515
516 GUILayout.EndHorizontal();
517 }
518 else if (this.photonSetupState == PhotonSetupStates.SetupPhotonCloud)
519 {
520 // cloud setup
521 GUI.skin.label.fontStyle = FontStyle.Bold;
522 GUILayout.Label(CurrentLang.PhotonCloudConnect);
523 GUI.skin.label.fontStyle = FontStyle.Normal;
524
525 EditorGUILayout.Separator();
526 this.OnGuiSetupCloudAppId();
527 this.OnGuiCompareAndHelpOptions();
528 }
529 else if (this.photonSetupState == PhotonSetupStates.SetupSelfHosted)
530 {
531 // self-hosting setup
532 GUI.skin.label.fontStyle = FontStyle.Bold;
533 GUILayout.Label(CurrentLang.SetupOwnHostLabel);
534 GUI.skin.label.fontStyle = FontStyle.Normal;
535
536 EditorGUILayout.Separator();
537
538 this.OnGuiSetupSelfhosting();
539 this.OnGuiCompareAndHelpOptions();
540 }
541 }
File name: PhotonEditor.cs
Copy
630 protected virtual void OnGuiCompareAndHelpOptions()
631 {
632 GUILayout.FlexibleSpace();
633
634 GUILayout.Label(CurrentLang.QuestionsLabel);
635 if (GUILayout.Button(CurrentLang.SeeForumButton))
636 {
637 Application.OpenURL(UrlForum);
638 }
639
640 if (photonSetupState != PhotonSetupStates.SetupSelfHosted)
641 {
642 if (GUILayout.Button(CurrentLang.OpenDashboardButton))
643 {
644 EditorUtility.OpenWithDefaultApp(UrlCloudDashboard + Uri.EscapeUriString(this.emailAddress));
645 }
646 }
647 }
File name: PhotonEditor.cs
Copy
649 protected virtual void OnGuiSetupCloudAppId()
650 {
651 GUILayout.Label(CurrentLang.AppIdLabel);
652
653 GUILayout.BeginHorizontal();
654 this.cloudAppId = EditorGUILayout.TextField(this.cloudAppId);
655
656 open = GUILayout.Toggle(open, PhotonGUI.HelpIcon, GUIStyle.none, GUILayout.ExpandWidth(false));
657
658 GUILayout.EndHorizontal();
659
660 if (open) GUILayout.Label(CurrentLang.AppIdInfoLabel);
661
662
663
664 EditorGUILayout.Separator();
665
666 GUILayout.Label(CurrentLang.CloudRegionLabel);
667
668 GUILayout.BeginHorizontal();
669 int toolbarValue = GUILayout.Toolbar((int)selectedRegion, CloudServerRegionNames); // the enum CloudRegionCode is converted into a string[] in init (toolbar can't use enum)
670 helpRegion = GUILayout.Toggle( helpRegion, PhotonGUI.HelpIcon, GUIStyle.none, GUILayout.ExpandWidth( false ) );
671 GUILayout.EndHorizontal();
672
673
674 if (helpRegion) GUILayout.Label(CurrentLang.RegionalServersInfo);
675 PhotonEditor.selectedRegion = (CloudRegionCode)toolbarValue;
676
677 EditorGUILayout.Separator();
678
679 GUILayout.BeginHorizontal();
680 if (GUILayout.Button(CurrentLang.CancelButton))
681 {
682 GUIUtility.keyboardControl = 0;
683 this.ReApplySettingsToWindow();
684 }
685
686
687
688 if (GUILayout.Button(CurrentLang.SaveButton))
689 {
690 GUIUtility.keyboardControl = 0;
691 this.cloudAppId = this.cloudAppId.Trim();
692 PhotonEditor.Current.UseCloud(this.cloudAppId);
693
694 PhotonEditor.Current.PreferredRegion = PhotonEditor.selectedRegion;
695 PhotonEditor.Current.HostType = (PhotonEditor.Current.PreferredRegion == CloudRegionCode.none)
696 ? ServerSettings.HostingOption.BestRegion
697 : ServerSettings.HostingOption.PhotonCloud;
698 PhotonEditor.Save();
699
700 Inspect();
701 EditorUtility.DisplayDialog(CurrentLang.SettingsSavedTitle, CurrentLang.SettingsSavedMessage, CurrentLang.OkButton);
702 }
703
704 GUILayout.EndHorizontal();
705
706
707
708 GUILayout.Space(20);
709
710 GUILayout.Label(CurrentLang.SetupOwnServerLabel);
711
712 if (GUILayout.Button(CurrentLang.SelfHostSettingsButton))
713 {
714 //this.photonAddress = ServerSettings.DefaultServerAddress;
715 //this.photonPort = ServerSettings.DefaultMasterPort;
716 this.photonSetupState = PhotonSetupStates.SetupSelfHosted;
717 }
718
719 EditorGUILayout.Separator();
720 GUILayout.Label(CurrentLang.OwnHostCloudCompareLabel);
721 if (GUILayout.Button(CurrentLang.ComparisonPageButton))
722 {
723 Application.OpenURL(UrlCompare);
724 }
725 }
SetupSelfHosted 123 lượt xem
Gõ tìm kiếm nhanh...