ServerSettings.FindRegionForServerAddress C# (CSharp) Method

FindRegionForServerAddress() public static method

public static FindRegionForServerAddress ( string server ) : int
server string
return int
    public static int FindRegionForServerAddress(string server)
    {
        int result = 0;

        for (int i = 0; i < CloudServerRegionPrefixes.Length; i++)
        {
            if (server.StartsWith(CloudServerRegionPrefixes[i]))
            {
                return i;
            }
        }

        return result;
    }

Usage Example

Example #1
0
    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);
        }
    }
All Usage Examples Of ServerSettings::FindRegionForServerAddress