Beispiel #1
0
 public CloudPanelPref(string serviceName)
 {
     this.m_ServiceName          = serviceName;
     this.m_CloudPanelServer     = UnityConnectPrefs.GetServiceEnv(this.m_ServiceName);
     this.m_CloudPanelCustomUrl  = EditorPrefs.GetString(UnityConnectPrefs.ServicePrefKey("CloudPanelCustomUrl", this.m_ServiceName));
     this.m_CloudPanelCustomPort = EditorPrefs.GetInt(UnityConnectPrefs.ServicePrefKey("CloudPanelCustomPort", this.m_ServiceName));
 }
        public static string FixUrl(string url, string serviceName)
        {
            string str1       = url;
            int    serviceEnv = UnityConnectPrefs.GetServiceEnv(serviceName);

            if (serviceEnv != 0)
            {
                if (str1.StartsWith("http://") || str1.StartsWith("https://"))
                {
                    return(serviceEnv != 3 ? str1.ToLower().Replace("/" + UnityConnectPrefs.kEnvironmentFamilies[0].ToLower() + "/", "/" + UnityConnectPrefs.kEnvironmentFamilies[serviceEnv].ToLower() + "/") : EditorPrefs.GetString(UnityConnectPrefs.ServicePrefKey("CloudPanelCustomUrl", serviceName)) + ":" + (object)EditorPrefs.GetInt(UnityConnectPrefs.ServicePrefKey("CloudPanelCustomPort", serviceName)));
                }
                if (str1.StartsWith("file://"))
                {
                    string str2 = str1.Substring(7);
                    if (serviceEnv == 3)
                    {
                        str2 = EditorPrefs.GetString(UnityConnectPrefs.ServicePrefKey("CloudPanelCustomUrl", serviceName)) + ":" + (object)EditorPrefs.GetInt(UnityConnectPrefs.ServicePrefKey("CloudPanelCustomPort", serviceName));
                    }
                    return(str2);
                }
                if (!str1.StartsWith("file://") && !str1.StartsWith("http://") && !str1.StartsWith("https://"))
                {
                    return("http://" + str1);
                }
            }
            return(str1);
        }
        private void EnsureDrawerIsVisible(bool forceFocus)
        {
            if (UnityConnectServiceCollection.s_UnityConnectEditorWindow == null || !UnityConnectServiceCollection.s_UnityConnectEditorWindow.UrlsMatch(this.GetAllServiceUrls()))
            {
                string text       = "Services";
                int    serviceEnv = UnityConnectPrefs.GetServiceEnv(this.m_CurrentServiceName);
                if (serviceEnv != 0)
                {
                    text = text + " [" + UnityConnectPrefs.kEnvironmentFamilies[serviceEnv] + "]";
                }
                UnityConnectServiceCollection.s_UnityConnectEditorWindow          = UnityConnectEditorWindow.Create(text, this.GetAllServiceUrls());
                UnityConnectServiceCollection.s_UnityConnectEditorWindow.ErrorUrl = this.m_Services["ErrorHub"].serviceUrl;
                UnityConnectServiceCollection.s_UnityConnectEditorWindow.minSize  = new Vector2(275f, 50f);
            }
            string text2 = this.m_Services[this.m_CurrentServiceName].serviceUrl;

            if (this.m_CurrentPageName.Length > 0)
            {
                text2 = text2 + "/#/" + this.m_CurrentPageName;
            }
            UnityConnectServiceCollection.s_UnityConnectEditorWindow.currentUrl = text2;
            UnityConnectServiceCollection.s_UnityConnectEditorWindow.ShowTab();
            if (InternalEditorUtility.isApplicationActive && forceFocus)
            {
                UnityConnectServiceCollection.s_UnityConnectEditorWindow.Focus();
            }
        }
Beispiel #4
0
        private void EnsureDrawerIsVisible(bool forceFocus)
        {
            //Create the container in case it doesnt exist
            if (s_UnityConnectEditorWindow == null || !s_UnityConnectEditorWindow.UrlsMatch(GetAllServiceUrls()))
            {
                var fixTitle = kDrawerContainerTitle;

                var panelEnv = UnityConnectPrefs.GetServiceEnv(m_CurrentServiceName);
                if (panelEnv != UnityConnectPrefs.kProductionEnv)
                {
                    fixTitle += " [" + UnityConnectPrefs.kEnvironmentFamilies[panelEnv] + "]";
                }

                s_UnityConnectEditorWindow          = UnityConnectEditorWindow.Create(fixTitle, GetAllServiceUrls());
                s_UnityConnectEditorWindow.ErrorUrl = m_Services[ErrorHubAccess.kServiceName].serviceUrl;
                s_UnityConnectEditorWindow.minSize  = new Vector2(275, 50);
            }
            //Since s_UnityConnectEditorWindow.currentUrl is a property that load a page we must build the url before changing it
            var newUrl = m_Services[m_CurrentServiceName].serviceUrl;

            if (m_CurrentPageName.Length > 0)
            {
                newUrl += ("/#/" + m_CurrentPageName);
            }
            s_UnityConnectEditorWindow.currentUrl = newUrl;
            s_UnityConnectEditorWindow.ShowTab();

            if (InternalEditorUtility.isApplicationActive && forceFocus)
            {
                s_UnityConnectEditorWindow.Focus();
            }
        }
Beispiel #5
0
        private void EnsureDrawerIsVisible(bool forceFocus)
        {
            if ((UnityEngine.Object)UnityConnectServiceCollection.s_UnityConnectEditorWindow == (UnityEngine.Object)null || !UnityConnectServiceCollection.s_UnityConnectEditorWindow.UrlsMatch(this.GetAllServiceUrls()))
            {
                string title      = "Services";
                int    serviceEnv = UnityConnectPrefs.GetServiceEnv(this.m_CurrentServiceName);
                if (serviceEnv != 0)
                {
                    title = title + " [" + UnityConnectPrefs.kEnvironmentFamilies[serviceEnv] + "]";
                }
                UnityConnectServiceCollection.s_UnityConnectEditorWindow          = UnityConnectEditorWindow.Create(title, this.GetAllServiceUrls());
                UnityConnectServiceCollection.s_UnityConnectEditorWindow.ErrorUrl = this.m_Services["ErrorHub"].serviceUrl;
                UnityConnectServiceCollection.s_UnityConnectEditorWindow.minSize  = new Vector2(275f, 50f);
            }
            string str = this.m_Services[this.m_CurrentServiceName].serviceUrl;

            if (this.m_CurrentPageName.Length > 0)
            {
                str = str + "/#/" + this.m_CurrentPageName;
            }
            UnityConnectServiceCollection.s_UnityConnectEditorWindow.currentUrl = str;
            UnityConnectServiceCollection.s_UnityConnectEditorWindow.Show();
            if (!InternalEditorUtility.isApplicationActive || !forceFocus)
            {
                return;
            }
            UnityConnectServiceCollection.s_UnityConnectEditorWindow.Focus();
        }
 public static int GetServiceEnv(string serviceName)
 {
     if (Unsupported.IsDeveloperBuild() || UnityConnect.preferencesEnabled)
     {
         return(EditorPrefs.GetInt(UnityConnectPrefs.ServicePrefKey("CloudPanelServer", serviceName)));
     }
     for (int index = 0; index < UnityConnectPrefs.kEnvironmentFamilies.Length; ++index)
     {
         if (UnityConnectPrefs.kEnvironmentFamilies[index].Equals(UnityConnect.instance.configuration, StringComparison.InvariantCultureIgnoreCase))
         {
             return(index);
         }
     }
     return(0);
 }
        public static string FixUrl(string url, string serviceName)
        {
            int    serviceEnv = UnityConnectPrefs.GetServiceEnv(serviceName);
            string result;

            if (serviceEnv != 0)
            {
                if (url.StartsWith("http://") || url.StartsWith("https://"))
                {
                    string text;
                    if (serviceEnv == 3)
                    {
                        string @string = EditorPrefs.GetString(UnityConnectPrefs.ServicePrefKey("CloudPanelCustomUrl", serviceName));
                        int    @int    = EditorPrefs.GetInt(UnityConnectPrefs.ServicePrefKey("CloudPanelCustomPort", serviceName));
                        text = ((@int != 0) ? (@string + ":" + @int) : @string);
                    }
                    else
                    {
                        text = url.ToLower();
                        text = text.Replace("/" + UnityConnectPrefs.kEnvironmentFamilies[0].ToLower() + "/", "/" + UnityConnectPrefs.kEnvironmentFamilies[serviceEnv].ToLower() + "/");
                    }
                    result = text;
                    return(result);
                }
                if (url.StartsWith("file://"))
                {
                    string text = url.Substring(7);
                    if (serviceEnv == 3)
                    {
                        string string2 = EditorPrefs.GetString(UnityConnectPrefs.ServicePrefKey("CloudPanelCustomUrl", serviceName));
                        int    int2    = EditorPrefs.GetInt(UnityConnectPrefs.ServicePrefKey("CloudPanelCustomPort", serviceName));
                        text = string2 + ":" + int2;
                    }
                    result = text;
                    return(result);
                }
                if (!url.StartsWith("file://") && !url.StartsWith("http://") && !url.StartsWith("https://"))
                {
                    string text = "http://" + url;
                    result = text;
                    return(result);
                }
            }
            result = url;
            return(result);
        }
        public static void ShowPanelPrefUI()
        {
            List <string> allServiceNames = UnityConnectServiceCollection.instance.GetAllServiceNames();
            bool          flag            = false;

            using (List <string> .Enumerator enumerator = allServiceNames.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    string current = enumerator.Current;
                    UnityConnectPrefs.CloudPanelPref panelPref = UnityConnectPrefs.GetPanelPref(current);
                    int result = EditorGUILayout.Popup(current, panelPref.m_CloudPanelServer, UnityConnectPrefs.kEnvironmentFamilies, new GUILayoutOption[0]);
                    if (result != panelPref.m_CloudPanelServer)
                    {
                        panelPref.m_CloudPanelServer = result;
                        flag = true;
                    }
                    if (panelPref.m_CloudPanelServer == 3)
                    {
                        ++EditorGUI.indentLevel;
                        string str = EditorGUILayout.TextField("Custom server URL", panelPref.m_CloudPanelCustomUrl, new GUILayoutOption[0]);
                        if (str != panelPref.m_CloudPanelCustomUrl)
                        {
                            panelPref.m_CloudPanelCustomUrl = str;
                            flag = true;
                        }
                        int.TryParse(EditorGUILayout.TextField("Custom server port", panelPref.m_CloudPanelCustomPort.ToString(), new GUILayoutOption[0]), out result);
                        if (result != panelPref.m_CloudPanelCustomPort)
                        {
                            panelPref.m_CloudPanelCustomPort = result;
                            flag = true;
                        }
                        --EditorGUI.indentLevel;
                    }
                }
            }
            if (!flag)
            {
                return;
            }
            UnityConnectServiceCollection.instance.ReloadServices();
        }
        public static int GetServiceEnv(string serviceName)
        {
            int result;

            if (Unsupported.IsDeveloperBuild() || UnityConnect.preferencesEnabled)
            {
                result = EditorPrefs.GetInt(UnityConnectPrefs.ServicePrefKey("CloudPanelServer", serviceName));
            }
            else
            {
                for (int i = 0; i < UnityConnectPrefs.kEnvironmentFamilies.Length; i++)
                {
                    string text = UnityConnectPrefs.kEnvironmentFamilies[i];
                    if (text.Equals(UnityConnect.instance.configuration, StringComparison.InvariantCultureIgnoreCase))
                    {
                        result = i;
                        return(result);
                    }
                }
                result = 0;
            }
            return(result);
        }
        public static void ShowPanelPrefUI()
        {
            List <string> allServiceNames = UnityConnectServiceCollection.instance.GetAllServiceNames();
            bool          flag            = false;

            foreach (string current in allServiceNames)
            {
                UnityConnectPrefs.CloudPanelPref panelPref = UnityConnectPrefs.GetPanelPref(current);
                int num = EditorGUILayout.Popup(current, panelPref.m_CloudPanelServer, UnityConnectPrefs.kEnvironmentFamilies, new GUILayoutOption[0]);
                if (num != panelPref.m_CloudPanelServer)
                {
                    panelPref.m_CloudPanelServer = num;
                    flag = true;
                }
                if (panelPref.m_CloudPanelServer == 3)
                {
                    EditorGUI.indentLevel++;
                    string text = EditorGUILayout.TextField("Custom server URL", panelPref.m_CloudPanelCustomUrl, new GUILayoutOption[0]);
                    if (text != panelPref.m_CloudPanelCustomUrl)
                    {
                        panelPref.m_CloudPanelCustomUrl = text;
                        flag = true;
                    }
                    int.TryParse(EditorGUILayout.TextField("Custom server port", panelPref.m_CloudPanelCustomPort.ToString(), new GUILayoutOption[0]), out num);
                    if (num != panelPref.m_CloudPanelCustomPort)
                    {
                        panelPref.m_CloudPanelCustomPort = num;
                        flag = true;
                    }
                    EditorGUI.indentLevel--;
                }
            }
            if (flag)
            {
                UnityConnectServiceCollection.instance.ReloadServices();
            }
        }
Beispiel #11
0
 public void StoreCloudServicePref()
 {
     EditorPrefs.SetInt(UnityConnectPrefs.ServicePrefKey("CloudPanelServer", this.m_ServiceName), this.m_CloudPanelServer);
     EditorPrefs.SetString(UnityConnectPrefs.ServicePrefKey("CloudPanelCustomUrl", this.m_ServiceName), this.m_CloudPanelCustomUrl);
     EditorPrefs.SetInt(UnityConnectPrefs.ServicePrefKey("CloudPanelCustomPort", this.m_ServiceName), this.m_CloudPanelCustomPort);
 }