public override void OnGUI(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor)
        {
            if (prop.type != MaterialProperty.PropType.Float && prop.type != MaterialProperty.PropType.Range)
            {
                GUIContent c = EditorGUIUtility.TempContent("Enum used on a non-float property: " + prop.name,
                                                            EditorGUIUtility.GetHelpIcon(MessageType.Warning));
                EditorGUI.LabelField(position, c, EditorStyles.helpBox);
                return;
            }

            EditorGUI.BeginChangeCheck();
            EditorGUI.showMixedValue = prop.hasMixedValue;

            var value         = prop.floatValue;
            int selectedIndex = -1;

            for (var index = 0; index < values.Length; index++)
            {
                var i = values[index];
                if (i == value)
                {
                    selectedIndex = index;
                    break;
                }
            }

            var selIndex = EditorGUI.Popup(position, label, selectedIndex, names);

            EditorGUI.showMixedValue = false;
            if (EditorGUI.EndChangeCheck())
            {
                prop.floatValue = values[selIndex];
            }
        }
        protected override bool DrawWizardGUI()
        {
            EditorGUI.BeginChangeCheck();

            Rect r = EditorGUILayout.GetControlRect(true, EditorGUIUtility.singleLineHeight);

            m_DetailTexture = EditorGUI.ObjectField(r, "Detail Texture", m_DetailTexture, typeof(Texture2D), !TerrainDataIsPersistent) as Texture2D;

            m_AlignToGround       = EditorGUILayout.Slider(DetailWizardSharedStyles.Instance.alignToGround, m_AlignToGround, 0, 100);
            m_PositionOrderliness = EditorGUILayout.Slider(DetailWizardSharedStyles.Instance.positionOrderliness, m_PositionOrderliness, 0, 100);
            m_MinWidth            = EditorGUILayout.FloatField("Min Width", m_MinWidth);
            m_MaxWidth            = EditorGUILayout.FloatField("Max Width", m_MaxWidth);
            m_MinHeight           = EditorGUILayout.FloatField("Min Height", m_MinHeight);
            m_MaxHeight           = EditorGUILayout.FloatField("Max Height", m_MaxHeight);
            m_NoiseSeed           = EditorGUILayout.IntField(DetailWizardSharedStyles.Instance.noiseSeed, m_NoiseSeed);
            m_NoiseSpread         = EditorGUILayout.FloatField(DetailWizardSharedStyles.Instance.noiseSpread, m_NoiseSpread);
            GUI.enabled           = terrainData.detailScatterMode == DetailScatterMode.CoverageMode;
            m_DetailDensity       = EditorGUILayout.Slider(DetailWizardSharedStyles.Instance.detailDensity, m_DetailDensity, 0, 5);
            GUI.enabled           = true;
            m_HoleEdgePadding     = EditorGUILayout.Slider(DetailWizardSharedStyles.Instance.holeEdgePadding, m_HoleEdgePadding, 0, 100);

            m_HealthyColor = EditorGUILayout.ColorField("Healthy Color", m_HealthyColor);
            m_DryColor     = EditorGUILayout.ColorField("Dry Color", m_DryColor);

            m_Billboard = EditorGUILayout.Toggle("Billboard", m_Billboard);

            m_UseDensityScaling = EditorGUILayout.Toggle(DetailWizardSharedStyles.Instance.useDensityScaling, m_UseDensityScaling);

            if (!DetailPrototype.IsModeSupportedByRenderPipeline(ComputeRenderMode(m_Billboard), false, out var message))
            {
                EditorGUILayout.LabelField(EditorGUIUtility.TempContent(message, EditorGUIUtility.GetHelpIcon(MessageType.Error)), DetailWizardSharedStyles.Instance.helpBoxBig);
            }

            return(EditorGUI.EndChangeCheck());
        }
        protected override bool DrawWizardGUI()
        {
            EditorGUI.BeginChangeCheck();

            m_DetailPrefab        = EditorGUILayout.ObjectField("Detail Prefab", m_DetailPrefab, typeof(GameObject), !TerrainDataIsPersistent) as GameObject;
            GUI.enabled           = terrainData.detailScatterMode == DetailScatterMode.CoverageMode;
            m_DetailDensity       = EditorGUILayout.Slider(DetailWizardSharedStyles.Instance.detailDensity, m_DetailDensity, 0, 3);
            GUI.enabled           = true;
            m_AlignToGround       = EditorGUILayout.Slider(DetailWizardSharedStyles.Instance.alignToGround, m_AlignToGround, 0, 100);
            m_PositionOrderliness = EditorGUILayout.Slider(DetailWizardSharedStyles.Instance.positionOrderliness, m_PositionOrderliness, 0, 100);
            m_MinWidth            = EditorGUILayout.FloatField("Min Width", m_MinWidth);
            m_MaxWidth            = EditorGUILayout.FloatField("Max Width", m_MaxWidth);
            m_MinHeight           = EditorGUILayout.FloatField("Min Height", m_MinHeight);
            m_MaxHeight           = EditorGUILayout.FloatField("Max Height", m_MaxHeight);
            m_NoiseSeed           = EditorGUILayout.IntField(DetailWizardSharedStyles.Instance.noiseSeed, m_NoiseSeed);
            m_NoiseSpread         = EditorGUILayout.FloatField(DetailWizardSharedStyles.Instance.noiseSpread, m_NoiseSpread);
            m_HoleEdgePadding     = EditorGUILayout.Slider(DetailWizardSharedStyles.Instance.holeEdgePadding, m_HoleEdgePadding, 0, 100);

            GUI.enabled     = terrainData.detailScatterMode == DetailScatterMode.CoverageMode;
            m_DetailDensity = EditorGUILayout.Slider(DetailWizardSharedStyles.Instance.detailDensity, m_DetailDensity, 0, 5);
            GUI.enabled     = true;

            if (!m_UseInstancing)
            {
                m_HealthyColor = EditorGUILayout.ColorField("Healthy Color", m_HealthyColor);
                m_DryColor     = EditorGUILayout.ColorField("Dry Color", m_DryColor);
            }

            if (m_UseInstancing)
            {
                EditorGUI.BeginDisabled(true);
                EditorGUILayout.EnumPopup("Render Mode", TerrainDetailMeshRenderMode.VertexLit);
                EditorGUI.EndDisabled();
            }
            else
            {
                m_RenderMode = (TerrainDetailMeshRenderMode)EditorGUILayout.EnumPopup("Render Mode", m_RenderMode);
            }

            m_UseInstancing = EditorGUILayout.Toggle("Use GPU Instancing", m_UseInstancing);
            if (m_UseInstancing)
            {
                EditorGUILayout.HelpBox("Using GPU Instancing would enable using the Material you set on the prefab.", MessageType.Info);
            }

            m_UseDensityScaling = EditorGUILayout.Toggle(DetailWizardSharedStyles.Instance.useDensityScaling, m_UseDensityScaling);

            if (!DetailPrototype.IsModeSupportedByRenderPipeline(ComputeRenderMode(), m_UseInstancing, out var message))
            {
                EditorGUILayout.LabelField(EditorGUIUtility.TempContent(message, EditorGUIUtility.GetHelpIcon(MessageType.Error)), DetailWizardSharedStyles.Instance.helpBoxBig);
            }

            return(EditorGUI.EndChangeCheck());
        }
        public override void OnGUI(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor)
        {
            if (prop.type != MaterialProperty.PropType.Range)
            {
                GUIContent c = EditorGUIUtility.TempContent("IntRange used on a non-range property: " + prop.name,
                                                            EditorGUIUtility.GetHelpIcon(MessageType.Warning));
                EditorGUI.LabelField(position, c, EditorStyles.helpBox);
                return;
            }

            MaterialEditor.DoIntRangeProperty(position, prop, label);
        }
        public override void OnGUI(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor)
        {
            if (!IsPropertyTypeSuitable(prop))
            {
                GUIContent c = EditorGUIUtility.TempContent("KeywordEnum used on a non-float property: " + prop.name,
                                                            EditorGUIUtility.GetHelpIcon(MessageType.Warning));
                EditorGUI.LabelField(position, c, EditorStyles.helpBox);
                return;
            }

            MaterialEditor.BeginProperty(position, prop);

            if (prop.type != MaterialProperty.PropType.Int)
            {
                EditorGUI.BeginChangeCheck();

                EditorGUI.showMixedValue = prop.hasMixedValue;
                var value = (int)prop.floatValue;
                value = EditorGUI.Popup(position, label, value, keywords);
                EditorGUI.showMixedValue = false;
                if (EditorGUI.EndChangeCheck())
                {
                    prop.floatValue = value;
                    SetKeyword(prop, value);
                }
            }
            else
            {
                EditorGUI.BeginChangeCheck();

                EditorGUI.showMixedValue = prop.hasMixedValue;
                var value = prop.intValue;
                value = EditorGUI.Popup(position, label, value, keywords);
                EditorGUI.showMixedValue = false;
                if (EditorGUI.EndChangeCheck())
                {
                    prop.intValue = value;
                    SetKeyword(prop, value);
                }
            }

            MaterialEditor.EndProperty();
        }
        public static GUIContent TextContentWithIcon(string text, MessageType messageType)
        {
            if (!LocalizationDatabase.enableEditorLocalization)
            {
                return(EditorGUIUtility.TrTextContentWithIcon(text, messageType));
            }

            var groupName = GetGroupName(Assembly.GetCallingAssembly());

            if (groupName != null)
            {
                var new_text = LocalizationDatabase.GetLocalizedStringWithGroupName(text, groupName);
                var gc       = new GUIContent(new_text);
                gc.image = EditorGUIUtility.GetHelpIcon(messageType);
                return(gc);
            }
            else
            {
                return(EditorGUIUtility.TrTextContentWithIcon(text, messageType));
            }
        }
示例#7
0
        bool HelpBoxWithButton(GUIContent messageContent, GUIContent buttonContent, MessageType type)
        {
            const float kButtonWidth  = 60f;
            const float kSpacing      = 5f;
            const float kButtonHeight = 20f;

            // Reserve size of wrapped text
            Rect contentRect = GUILayoutUtility.GetRect(messageContent, EditorStyles.helpBox);

            // Reserve size of button
            GUILayoutUtility.GetRect(1, kButtonHeight + kSpacing);

            // Render background box with text at full height
            contentRect.height += kButtonHeight + kSpacing;
            GUI.Label(contentRect, EditorGUIUtility.TempContent(messageContent.text, EditorGUIUtility.GetHelpIcon(type)), EditorStyles.helpBox);

            // Button (align lower right)
            Rect buttonRect = new Rect(contentRect.xMax - kButtonWidth - 4f, contentRect.yMax - kButtonHeight - 4f, kButtonWidth, kButtonHeight);

            return(GUI.Button(buttonRect, buttonContent));
        }
        public override void OnGUI(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor)
        {
            if (prop.type != MaterialProperty.PropType.Float && prop.type != MaterialProperty.PropType.Range)
            {
                GUIContent c = EditorGUIUtility.TempContent("Enum used on a non-float property: " + prop.name,
                                                            EditorGUIUtility.GetHelpIcon(MessageType.Warning));
                EditorGUI.LabelField(position, c, EditorStyles.helpBox);
                return;
            }

            EditorGUI.BeginChangeCheck();

            EditorGUI.showMixedValue = prop.hasMixedValue;
            var value = (int)prop.floatValue;

            value = EditorGUI.IntPopup(position, label, value, names, values);
            EditorGUI.showMixedValue = false;
            if (EditorGUI.EndChangeCheck())
            {
                prop.floatValue = value;
            }
        }
        public override void OnGUI(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor)
        {
            if (!IsPropertyTypeSuitable(prop))
            {
                GUIContent c = EditorGUIUtility.TempContent("Toggle used on a non-float property: " + prop.name,
                                                            EditorGUIUtility.GetHelpIcon(MessageType.Warning));
                EditorGUI.LabelField(position, c, EditorStyles.helpBox);
                return;
            }

            EditorGUI.BeginChangeCheck();

            bool value = (Math.Abs(prop.floatValue) > 0.001f);

            EditorGUI.showMixedValue = prop.hasMixedValue;
            value = EditorGUI.Toggle(position, label, value);
            EditorGUI.showMixedValue = false;
            if (EditorGUI.EndChangeCheck())
            {
                prop.floatValue = value ? 1.0f : 0.0f;
                SetKeyword(prop, value);
            }
        }
		public static void OnGUI()
		{
			EventType type = Event.current.type;
			if (CacheServerPreferences.s_Constants == null)
			{
				CacheServerPreferences.s_Constants = new CacheServerPreferences.Constants();
			}
			if (!InternalEditorUtility.HasTeamLicense())
			{
				GUILayout.Label(EditorGUIUtility.TempContent("You need to have a Pro or Team license to use the cache server.", EditorGUIUtility.GetHelpIcon(MessageType.Warning)), EditorStyles.helpBox, new GUILayoutOption[0]);
			}
			using (new EditorGUI.DisabledScope(!InternalEditorUtility.HasTeamLicense()))
			{
				if (!CacheServerPreferences.s_PrefsLoaded)
				{
					CacheServerPreferences.ReadPreferences();
					if (CacheServerPreferences.s_CacheServerMode != CacheServerPreferences.CacheServerMode.Disabled && CacheServerPreferences.s_ConnectionState == CacheServerPreferences.ConnectionState.Unknown)
					{
						if (InternalEditorUtility.CanConnectToCacheServer())
						{
							CacheServerPreferences.s_ConnectionState = CacheServerPreferences.ConnectionState.Success;
						}
						else
						{
							CacheServerPreferences.s_ConnectionState = CacheServerPreferences.ConnectionState.Failure;
						}
					}
					CacheServerPreferences.s_PrefsLoaded = true;
				}
				EditorGUI.BeginChangeCheck();
				CacheServerPreferences.s_CacheServerMode = (CacheServerPreferences.CacheServerMode)EditorGUILayout.EnumPopup("Cache Server Mode", CacheServerPreferences.s_CacheServerMode, new GUILayoutOption[0]);
				if (CacheServerPreferences.s_CacheServerMode == CacheServerPreferences.CacheServerMode.Remote)
				{
					CacheServerPreferences.s_CacheServerIPAddress = EditorGUILayout.DelayedTextField("IP Address", CacheServerPreferences.s_CacheServerIPAddress, new GUILayoutOption[0]);
					if (GUI.changed)
					{
						CacheServerPreferences.s_ConnectionState = CacheServerPreferences.ConnectionState.Unknown;
					}
					GUILayout.Space(5f);
					if (GUILayout.Button("Check Connection", new GUILayoutOption[]
					{
						GUILayout.Width(150f)
					}))
					{
						if (InternalEditorUtility.CanConnectToCacheServer())
						{
							CacheServerPreferences.s_ConnectionState = CacheServerPreferences.ConnectionState.Success;
						}
						else
						{
							CacheServerPreferences.s_ConnectionState = CacheServerPreferences.ConnectionState.Failure;
						}
					}
					GUILayout.Space(-25f);
					CacheServerPreferences.ConnectionState connectionState = CacheServerPreferences.s_ConnectionState;
					if (connectionState != CacheServerPreferences.ConnectionState.Success)
					{
						if (connectionState != CacheServerPreferences.ConnectionState.Failure)
						{
							if (connectionState == CacheServerPreferences.ConnectionState.Unknown)
							{
								GUILayout.Space(44f);
							}
						}
						else
						{
							EditorGUILayout.HelpBox("Connection failed.", MessageType.Warning, false);
						}
					}
					else
					{
						EditorGUILayout.HelpBox("Connection successful.", MessageType.Info, false);
					}
				}
				else if (CacheServerPreferences.s_CacheServerMode == CacheServerPreferences.CacheServerMode.Local)
				{
					CacheServerPreferences.s_LocalCacheServerSize = EditorGUILayout.IntSlider(CacheServerPreferences.Styles.maxCacheSize, CacheServerPreferences.s_LocalCacheServerSize, 1, 200, new GUILayoutOption[0]);
					CacheServerPreferences.s_EnableCustomPath = EditorGUILayout.Toggle(CacheServerPreferences.Styles.customCacheLocation, CacheServerPreferences.s_EnableCustomPath, new GUILayoutOption[0]);
					if (CacheServerPreferences.s_EnableCustomPath)
					{
						GUIStyle miniButton = EditorStyles.miniButton;
						GUILayout.BeginHorizontal(new GUILayoutOption[0]);
						EditorGUILayout.PrefixLabel(CacheServerPreferences.Styles.cacheFolderLocation, miniButton);
						Rect rect = GUILayoutUtility.GetRect(GUIContent.none, miniButton);
						GUIContent content = (!string.IsNullOrEmpty(CacheServerPreferences.s_CachePath)) ? new GUIContent(CacheServerPreferences.s_CachePath) : CacheServerPreferences.Styles.browse;
						if (EditorGUI.DropdownButton(rect, content, FocusType.Passive, miniButton))
						{
							string folder = CacheServerPreferences.s_CachePath;
							string text = EditorUtility.OpenFolderPanel(CacheServerPreferences.Styles.browseCacheLocation.text, folder, "");
							if (!string.IsNullOrEmpty(text))
							{
								if (LocalCacheServer.CheckValidCacheLocation(text))
								{
									CacheServerPreferences.s_CachePath = text;
									CacheServerPreferences.WritePreferences();
								}
								else
								{
									EditorUtility.DisplayDialog("Invalid Cache Location", "The directory " + text + " contains some files which don't look like Unity Cache server files. Please delete the directory contents or choose another directory.", "OK");
								}
								GUIUtility.ExitGUI();
							}
						}
						GUILayout.EndHorizontal();
					}
					else
					{
						CacheServerPreferences.s_CachePath = "";
					}
					bool flag = LocalCacheServer.CheckCacheLocationExists();
					if (flag)
					{
						GUIContent label = EditorGUIUtility.TextContent("Cache size is unknown");
						if (CacheServerPreferences.s_LocalCacheServerUsedSize != -1L)
						{
							label = EditorGUIUtility.TextContent("Cache size is " + EditorUtility.FormatBytes(CacheServerPreferences.s_LocalCacheServerUsedSize));
						}
						GUILayout.BeginHorizontal(new GUILayoutOption[0]);
						GUIStyle miniButton2 = EditorStyles.miniButton;
						EditorGUILayout.PrefixLabel(label, miniButton2);
						Rect rect2 = GUILayoutUtility.GetRect(GUIContent.none, miniButton2);
						if (EditorGUI.Button(rect2, CacheServerPreferences.Styles.enumerateCache, miniButton2))
						{
							CacheServerPreferences.s_LocalCacheServerUsedSize = ((!LocalCacheServer.CheckCacheLocationExists()) ? 0L : FileUtil.GetDirectorySize(LocalCacheServer.GetCacheLocation()));
						}
						GUILayout.EndHorizontal();
						GUILayout.BeginHorizontal(new GUILayoutOption[0]);
						GUIContent blankContent = EditorGUIUtility.blankContent;
						EditorGUILayout.PrefixLabel(blankContent, miniButton2);
						Rect rect3 = GUILayoutUtility.GetRect(GUIContent.none, miniButton2);
						if (EditorGUI.Button(rect3, CacheServerPreferences.Styles.cleanCache, miniButton2))
						{
							LocalCacheServer.Clear();
							CacheServerPreferences.s_LocalCacheServerUsedSize = 0L;
						}
						GUILayout.EndHorizontal();
					}
					else
					{
						EditorGUILayout.HelpBox("Local cache directory does not exist - please check that you can access the cache folder and are able to write to it", MessageType.Warning, false);
						CacheServerPreferences.s_LocalCacheServerUsedSize = -1L;
					}
					GUILayout.Label(CacheServerPreferences.Styles.cacheFolderLocation.text + ":", new GUILayoutOption[0]);
					GUILayout.Label(LocalCacheServer.GetCacheLocation(), CacheServerPreferences.s_Constants.cacheFolderLocation, new GUILayoutOption[0]);
				}
				if (EditorGUI.EndChangeCheck())
				{
					CacheServerPreferences.s_HasPendingChanges = true;
				}
				if (CacheServerPreferences.s_HasPendingChanges && GUIUtility.hotControl == 0)
				{
					CacheServerPreferences.s_HasPendingChanges = false;
					CacheServerPreferences.WritePreferences();
					CacheServerPreferences.ReadPreferences();
				}
			}
		}
 public override void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor)
 {
     if (prop.type != MaterialProperty.PropType.Range)
     {
         GUIContent content = EditorGUIUtility.TempContent("PowerSlider used on a non-range property: " + prop.name, EditorGUIUtility.GetHelpIcon(MessageType.Warning));
         EditorGUI.LabelField(position, content, EditorStyles.helpBox);
     }
     else
     {
         MaterialEditor.DoPowerRangeProperty(position, prop, label, this.power);
     }
 }
 public override void OnGUI(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor)
 {
     if (!MaterialToggleDrawer.IsPropertyTypeSuitable(prop))
     {
         GUIContent label2 = EditorGUIUtility.TempContent("Toggle used on a non-float property: " + prop.name, EditorGUIUtility.GetHelpIcon(MessageType.Warning));
         EditorGUI.LabelField(position, label2, EditorStyles.helpBox);
     }
     else
     {
         EditorGUI.BeginChangeCheck();
         bool flag = Math.Abs(prop.floatValue) > 0.001f;
         EditorGUI.showMixedValue = prop.hasMixedValue;
         flag = EditorGUI.Toggle(position, label, flag);
         EditorGUI.showMixedValue = false;
         if (EditorGUI.EndChangeCheck())
         {
             prop.floatValue = ((!flag) ? 0f : 1f);
             this.SetKeyword(prop, flag);
         }
     }
 }
示例#13
0
        private static void OnGUI(string searchContext)
        {
            EditorGUIUtility.labelWidth = 200f;
            // Get event type before the event is used.
            var eventType = Event.current.type;

            if (!InternalEditorUtility.HasTeamLicense())
            {
                GUILayout.Label(EditorGUIUtility.TempContent("You need to have a Pro or Team license to use the cache server.", EditorGUIUtility.GetHelpIcon(MessageType.Warning)), EditorStyles.helpBox);
            }


            using (new EditorGUI.DisabledScope(!InternalEditorUtility.HasTeamLicense()))
            {
                if (!s_PrefsLoaded)
                {
                    EnsurePreferencesRead();
                    OnPreferencesReadGUI();
                }

                EditorGUI.BeginChangeCheck();

                s_AssetPipelineVersionForNewProjects = (AssetPipelineVersion)EditorGUILayout.EnumPopup(Properties.newProjectsAssetPipeline, s_AssetPipelineVersionForNewProjects);

                EditorGUILayout.LabelField(Properties.activeAssetPipelineVersionLabel, Properties.activeAssetPipelineVersion);
                var  overrideAddress         = GetCommandLineRemoteAddressOverride();
                bool allowCacheServerChanges = overrideAddress == null;

                if (GetEnvironmentAssetPipelineOverride())
                {
                    EditorGUILayout.HelpBox("Asset pipeline currently forced enviroment variable UNITY_ASSETS_V2_KATANA_TESTS", MessageType.Info, true);
                }
                else if (GetCommandLineAssetPipelineOverride() != 0)
                {
                    EditorGUILayout.HelpBox("Asset pipeline currently forced by command line argument", MessageType.Info, true);
                }
                else if (GetMagicFileAssetPipelineOverride())
                {
                    EditorGUILayout.HelpBox("Asset pipeline currently forced by magic adb2.txt file", MessageType.Info, true);
                }

                GUILayout.Space(5);

                CacheServerVersion1GUI(allowCacheServerChanges, overrideAddress);

                GUILayout.Space(5);

                CacheServerVersion2GUI(allowCacheServerChanges, overrideAddress);
                GUILayout.Space(10);

                if (!allowCacheServerChanges)
                {
                    EditorGUILayout.HelpBox("Cache Server preferences currently forced via command line argument to " + overrideAddress + " and any changes here will not take effect until starting Unity without that command line argument.", MessageType.Info, true);
                }

                if (EditorGUI.EndChangeCheck())
                {
                    s_HasPendingChanges = true;
                }

                // Only commit changes when we don't have an active hot control, to avoid restarting the cache server all the time while the slider is dragged, slowing down the UI.
                if (s_HasPendingChanges && GUIUtility.hotControl == 0)
                {
                    s_HasPendingChanges = false;
                    WritePreferences();
                    ReadPreferences();
                }
            }
        }
        public static void OnGUI()
        {
            GUILayout.Space(10f);
            if (!InternalEditorUtility.HasTeamLicense())
            {
                GUILayout.Label(EditorGUIUtility.TempContent("You need to have a Pro or Team license to use the cache server.", EditorGUIUtility.GetHelpIcon(MessageType.Warning)), EditorStyles.helpBox, new GUILayoutOption[0]);
            }
            using (new EditorGUI.DisabledScope(!InternalEditorUtility.HasTeamLicense()))
            {
                if (!CacheServerPreferences.s_PrefsLoaded)
                {
                    CacheServerPreferences.ReadPreferences();
                    if (CacheServerPreferences.s_CacheServerEnabled && CacheServerPreferences.s_ConnectionState == CacheServerPreferences.ConnectionState.Unknown)
                    {
                        if (InternalEditorUtility.CanConnectToCacheServer())
                        {
                            CacheServerPreferences.s_ConnectionState = CacheServerPreferences.ConnectionState.Success;
                        }
                        else
                        {
                            CacheServerPreferences.s_ConnectionState = CacheServerPreferences.ConnectionState.Failure;
                        }
                    }
                    CacheServerPreferences.s_PrefsLoaded = true;
                }
                EditorGUI.BeginChangeCheck();
                if (Collab.instance.collabInfo.whitelisted)
                {
                    CacheServerPreferences.s_CollabCacheEnabled = EditorGUILayout.Toggle("Use Collab Cache", CacheServerPreferences.s_CollabCacheEnabled, new GUILayoutOption[0]);
                    using (new EditorGUI.DisabledScope(!CacheServerPreferences.s_CollabCacheEnabled))
                    {
                        CacheServerPreferences.s_CollabCacheIPAddress = EditorGUILayout.TextField("Collab Cache IP Address", CacheServerPreferences.s_CollabCacheIPAddress, new GUILayoutOption[0]);
                    }
                }
                CacheServerPreferences.s_CacheServerEnabled = EditorGUILayout.Toggle("Use Cache Server", CacheServerPreferences.s_CacheServerEnabled, new GUILayoutOption[0]);
                using (new EditorGUI.DisabledScope(!CacheServerPreferences.s_CacheServerEnabled))
                {
                    Rect controlRect = EditorGUILayout.GetControlRect(true, new GUILayoutOption[0]);
                    int  controlID   = GUIUtility.GetControlID(FocusType.Keyboard, controlRect);
                    CacheServerPreferences.s_CacheServerIPAddress = EditorGUI.DelayedTextFieldInternal(controlRect, controlID, GUIContent.Temp("IP Address"), CacheServerPreferences.s_CacheServerIPAddress, null, EditorStyles.textField);
                    if (GUI.changed)
                    {
                        CacheServerPreferences.s_ConnectionState = CacheServerPreferences.ConnectionState.Unknown;
                        CacheServerPreferences.WritePreferences();
                    }
                    GUILayout.Space(5f);
                    if (GUILayout.Button("Check Connection", new GUILayoutOption[]
                    {
                        GUILayout.Width(150f)
                    }))
                    {
                        if (EditorGUI.s_DelayedTextEditor.IsEditingControl(controlID))
                        {
                            string text = EditorGUI.s_DelayedTextEditor.text;
                            EditorGUI.s_DelayedTextEditor.EndEditing();
                            if (text != CacheServerPreferences.s_CacheServerIPAddress)
                            {
                                CacheServerPreferences.s_CacheServerIPAddress = text;
                                CacheServerPreferences.WritePreferences();
                            }
                        }
                        if (InternalEditorUtility.CanConnectToCacheServer())
                        {
                            CacheServerPreferences.s_ConnectionState = CacheServerPreferences.ConnectionState.Success;
                        }
                        else
                        {
                            CacheServerPreferences.s_ConnectionState = CacheServerPreferences.ConnectionState.Failure;
                        }
                    }
                    GUILayout.Space(-25f);
                    switch (CacheServerPreferences.s_ConnectionState)
                    {
                    case CacheServerPreferences.ConnectionState.Unknown:
                        GUILayout.Space(44f);
                        break;

                    case CacheServerPreferences.ConnectionState.Success:
                        EditorGUILayout.HelpBox("Connection successful.", MessageType.Info, false);
                        break;

                    case CacheServerPreferences.ConnectionState.Failure:
                        EditorGUILayout.HelpBox("Connection failed.", MessageType.Warning, false);
                        break;
                    }
                }
                if (EditorGUI.EndChangeCheck())
                {
                    CacheServerPreferences.WritePreferences();
                    CacheServerPreferences.ReadPreferences();
                }
            }
        }
        public override void OnInspectorGUI()
        {
            if (EditorApplication.isPlayingOrWillChangePlaymode)
            {
                EditorGUILayout.HelpBox("Changes made in play mode will not be saved.", MessageType.Warning, true);
            }

            m_QualitySettings.Update();

            var settings      = GetQualitySettings();
            var defaults      = GetDefaultQualityForPlatforms();
            var selectedLevel = QualitySettings.GetQualityLevel();

            if (selectedLevel >= m_QualitySettingsProperty.arraySize)
            {
                selectedLevel = m_QualitySettingsProperty.arraySize - 1;
            }

            EditorGUI.BeginChangeCheck();
            selectedLevel = DoQualityLevelSelection(selectedLevel, settings, defaults);
            if (EditorGUI.EndChangeCheck())
            {
                QualitySettings.SetQualityLevel(selectedLevel);
            }

            SetQualitySettings(settings);
            HandleAddRemoveQualitySetting(ref selectedLevel, defaults);
            SetDefaultQualityForPlatforms(defaults);
            GUILayout.Space(10.0f);
            DrawHorizontalDivider();
            GUILayout.Space(10.0f);

            var currentSettings                         = m_QualitySettingsProperty.GetArrayElementAtIndex(selectedLevel);
            var nameProperty                            = currentSettings.FindPropertyRelative("name");
            var pixelLightCountProperty                 = currentSettings.FindPropertyRelative("pixelLightCount");
            var shadowsProperty                         = currentSettings.FindPropertyRelative("shadows");
            var shadowResolutionProperty                = currentSettings.FindPropertyRelative("shadowResolution");
            var shadowProjectionProperty                = currentSettings.FindPropertyRelative("shadowProjection");
            var shadowCascadesProperty                  = currentSettings.FindPropertyRelative("shadowCascades");
            var shadowDistanceProperty                  = currentSettings.FindPropertyRelative("shadowDistance");
            var shadowNearPlaneOffsetProperty           = currentSettings.FindPropertyRelative("shadowNearPlaneOffset");
            var shadowCascade2SplitProperty             = currentSettings.FindPropertyRelative("shadowCascade2Split");
            var shadowCascade4SplitProperty             = currentSettings.FindPropertyRelative("shadowCascade4Split");
            var shadowMaskUsageProperty                 = currentSettings.FindPropertyRelative("shadowmaskMode");
            var skinWeightsProperty                     = currentSettings.FindPropertyRelative("skinWeights");
            var textureQualityProperty                  = currentSettings.FindPropertyRelative("textureQuality");
            var anisotropicTexturesProperty             = currentSettings.FindPropertyRelative("anisotropicTextures");
            var antiAliasingProperty                    = currentSettings.FindPropertyRelative("antiAliasing");
            var softParticlesProperty                   = currentSettings.FindPropertyRelative("softParticles");
            var realtimeReflectionProbes                = currentSettings.FindPropertyRelative("realtimeReflectionProbes");
            var billboardsFaceCameraPosition            = currentSettings.FindPropertyRelative("billboardsFaceCameraPosition");
            var vSyncCountProperty                      = currentSettings.FindPropertyRelative("vSyncCount");
            var lodBiasProperty                         = currentSettings.FindPropertyRelative("lodBias");
            var maximumLODLevelProperty                 = currentSettings.FindPropertyRelative("maximumLODLevel");
            var particleRaycastBudgetProperty           = currentSettings.FindPropertyRelative("particleRaycastBudget");
            var asyncUploadTimeSliceProperty            = currentSettings.FindPropertyRelative("asyncUploadTimeSlice");
            var asyncUploadBufferSizeProperty           = currentSettings.FindPropertyRelative("asyncUploadBufferSize");
            var asyncUploadPersistentBufferProperty     = currentSettings.FindPropertyRelative("asyncUploadPersistentBuffer");
            var resolutionScalingFixedDPIFactorProperty = currentSettings.FindPropertyRelative("resolutionScalingFixedDPIFactor");

            var customRenderPipeline = currentSettings.FindPropertyRelative("customRenderPipeline");

            bool usingSRP = GraphicsSettings.currentRenderPipeline != null;

            if (string.IsNullOrEmpty(nameProperty.stringValue))
            {
                nameProperty.stringValue = "Level " + selectedLevel;
            }

            GUILayout.Label(EditorGUIUtility.TempContent("Current Active Quality Level"), EditorStyles.boldLabel);

            EditorGUILayout.PropertyField(nameProperty);

            if (usingSRP)
            {
                EditorGUILayout.HelpBox("A Scriptable Render Pipeline is in use, some settings will not be used and are hidden", MessageType.Info);
            }
            GUILayout.Space(10);

            GUILayout.Label(EditorGUIUtility.TempContent("Rendering"), EditorStyles.boldLabel);

            RenderPipelineAssetSelector.Draw(Content.kRenderPipelineObject, m_QualitySettings, customRenderPipeline);
            if (!usingSRP)
            {
                EditorGUILayout.PropertyField(pixelLightCountProperty);
            }

            // still valid with SRP
            if (!usingSRP)
            {
                EditorGUILayout.PropertyField(antiAliasingProperty);
            }

            if (!SupportedRenderingFeatures.active.overridesRealtimeReflectionProbes)
            {
                EditorGUILayout.PropertyField(realtimeReflectionProbes);
            }
            EditorGUILayout.PropertyField(resolutionScalingFixedDPIFactorProperty);

            EditorGUILayout.PropertyField(vSyncCountProperty, Content.kVSyncCountLabel);

            if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android ||
                EditorUserBuildSettings.activeBuildTarget == BuildTarget.iOS ||
                EditorUserBuildSettings.activeBuildTarget == BuildTarget.tvOS)
            {
                if (vSyncCountProperty.intValue > 0)
                {
                    EditorGUILayout.HelpBox(EditorGUIUtility.TrTextContent($"VSync Count '{vSyncCountProperty.enumLocalizedDisplayNames[vSyncCountProperty.enumValueIndex]}' is ignored on Android, iOS and tvOS.", EditorGUIUtility.GetHelpIcon(MessageType.Warning)));
                }
            }

            bool shadowMaskSupported = SupportedRenderingFeatures.IsMixedLightingModeSupported(MixedLightingMode.Shadowmask);
            bool showShadowMaskUsage = shadowMaskSupported && !SupportedRenderingFeatures.active.overridesShadowmask;

            GUILayout.Space(10);
            GUILayout.Label(EditorGUIUtility.TempContent("Textures"), EditorStyles.boldLabel);

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(textureQualityProperty);
            if (EditorGUI.EndChangeCheck() && usingSRP)
            {
                RenderPipelineManager.CleanupRenderPipeline();
            }
            if (QualitySettings.IsTextureResReducedOnAnyPlatform())
            {
                MipStrippingHintGUI();
            }
            EditorGUILayout.PropertyField(anisotropicTexturesProperty);

            var streamingMipmapsActiveProperty = currentSettings.FindPropertyRelative("streamingMipmapsActive");

            EditorGUILayout.PropertyField(streamingMipmapsActiveProperty, Content.kStreamingMipmapsActive);
            if (streamingMipmapsActiveProperty.boolValue)
            {
                EditorGUI.indentLevel++;
                var streamingMipmapsAddAllCameras = currentSettings.FindPropertyRelative("streamingMipmapsAddAllCameras");
                EditorGUILayout.PropertyField(streamingMipmapsAddAllCameras, Content.kStreamingMipmapsAddAllCameras);
                var streamingMipmapsBudgetProperty = currentSettings.FindPropertyRelative("streamingMipmapsMemoryBudget");
                EditorGUILayout.PropertyField(streamingMipmapsBudgetProperty, Content.kStreamingMipmapsMemoryBudget);
                var streamingMipmapsRenderersPerFrameProperty = currentSettings.FindPropertyRelative("streamingMipmapsRenderersPerFrame");
                EditorGUILayout.PropertyField(streamingMipmapsRenderersPerFrameProperty, Content.kStreamingMipmapsRenderersPerFrame);
                var streamingMipmapsMaxLevelReductionProperty = currentSettings.FindPropertyRelative("streamingMipmapsMaxLevelReduction");
                EditorGUILayout.PropertyField(streamingMipmapsMaxLevelReductionProperty, Content.kStreamingMipmapsMaxLevelReduction);
                var streamingMipmapsMaxFileIORequestsProperty = currentSettings.FindPropertyRelative("streamingMipmapsMaxFileIORequests");
                EditorGUILayout.PropertyField(streamingMipmapsMaxFileIORequestsProperty, Content.kStreamingMipmapsMaxFileIORequests);
                EditorGUI.indentLevel--;
            }

            GUILayout.Space(10);
            GUILayout.Label(EditorGUIUtility.TempContent("Particles"), EditorStyles.boldLabel);
            if (!usingSRP)
            {
                EditorGUILayout.PropertyField(softParticlesProperty);
                if (softParticlesProperty.boolValue)
                {
                    SoftParticlesHintGUI();
                }
            }
            EditorGUILayout.PropertyField(particleRaycastBudgetProperty);

            GUILayout.Space(10);
            GUILayout.Label(EditorGUIUtility.TempContent("Terrain"), EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(billboardsFaceCameraPosition, Content.kBillboardsFaceCameraPos);

            if (!usingSRP || showShadowMaskUsage)
            {
                GUILayout.Space(10);

                GUILayout.Label(EditorGUIUtility.TempContent("Shadows"), EditorStyles.boldLabel);

                if (showShadowMaskUsage)
                {
                    EditorGUILayout.PropertyField(shadowMaskUsageProperty);
                }

                if (!usingSRP)
                {
                    EditorGUILayout.PropertyField(shadowsProperty);
                    EditorGUILayout.PropertyField(shadowResolutionProperty);
                    EditorGUILayout.PropertyField(shadowProjectionProperty);
                    EditorGUILayout.PropertyField(shadowDistanceProperty);
                    EditorGUILayout.PropertyField(shadowNearPlaneOffsetProperty);
                    EditorGUILayout.PropertyField(shadowCascadesProperty);

                    if (shadowCascadesProperty.intValue == 2)
                    {
                        DrawCascadeSplitGUI <float>(ref shadowCascade2SplitProperty);
                    }
                    else if (shadowCascadesProperty.intValue == 4)
                    {
                        DrawCascadeSplitGUI <Vector3>(ref shadowCascade4SplitProperty);
                    }
                }
            }

            GUILayout.Space(10);
            GUILayout.Label(EditorGUIUtility.TempContent("Async Asset Upload"), EditorStyles.boldLabel);

            EditorGUILayout.PropertyField(asyncUploadTimeSliceProperty, Content.kAsyncUploadTimeSlice);
            EditorGUILayout.PropertyField(asyncUploadBufferSizeProperty, Content.kAsyncUploadBufferSize);
            EditorGUILayout.PropertyField(asyncUploadPersistentBufferProperty, Content.kAsyncUploadPersistentBuffer);

            asyncUploadTimeSliceProperty.intValue  = Mathf.Clamp(asyncUploadTimeSliceProperty.intValue, kMinAsyncUploadTimeSlice, kMaxAsyncUploadTimeSlice);
            asyncUploadBufferSizeProperty.intValue = Mathf.Clamp(asyncUploadBufferSizeProperty.intValue, kMinAsyncRingBufferSize, kMaxAsyncRingBufferSize);

            GUILayout.Space(10);
            GUILayout.Label(EditorGUIUtility.TempContent("Level of Detail"), EditorStyles.boldLabel);

            if (!SupportedRenderingFeatures.active.overridesLODBias)
            {
                EditorGUILayout.PropertyField(lodBiasProperty, Content.kLODBiasLabel);
            }
            if (!SupportedRenderingFeatures.active.overridesMaximumLODLevel)
            {
                EditorGUILayout.PropertyField(maximumLODLevelProperty, Content.kMaximumLODLevelLabel);
            }

            GUILayout.Space(10);
            GUILayout.Label(EditorGUIUtility.TempContent("Meshes"), EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(skinWeightsProperty);

            if (m_Dragging != null && m_Dragging.m_Position != m_Dragging.m_StartPosition)
            {
                m_QualitySettingsProperty.MoveArrayElement(m_Dragging.m_StartPosition, m_Dragging.m_Position);
                m_Dragging.m_StartPosition = m_Dragging.m_Position;
                selectedLevel = m_Dragging.m_Position;

                m_QualitySettings.ApplyModifiedProperties();
                QualitySettings.SetQualityLevel(Mathf.Clamp(selectedLevel, 0, m_QualitySettingsProperty.arraySize - 1));
            }

            m_QualitySettings.ApplyModifiedProperties();
        }
示例#16
0
 public override void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor)
 {
     if (!IsPropertyTypeSuitable(prop))
     {
         GUIContent content = EditorGUIUtility.TempContent("KeywordEnum used on a non-float property: " + prop.name, EditorGUIUtility.GetHelpIcon(MessageType.Warning));
         EditorGUI.LabelField(position, content, EditorStyles.helpBox);
     }
     else
     {
         EditorGUI.BeginChangeCheck();
         EditorGUI.showMixedValue = prop.hasMixedValue;
         int floatValue = (int)prop.floatValue;
         floatValue = EditorGUI.Popup(position, label, floatValue, this.keywords);
         EditorGUI.showMixedValue = false;
         if (EditorGUI.EndChangeCheck())
         {
             prop.floatValue = floatValue;
             this.SetKeyword(prop, floatValue);
         }
     }
 }
        public ManagedDebuggerWindow(CodeOptimization codeOptimization)
        {
            m_CodeOptimization = codeOptimization;

            if (CodeOptimization.Debug == m_CodeOptimization)
            {
                m_CodeOptimizationTitleContent  = EditorGUIUtility.TrTextContent("Mode: Debug");
                m_CodeOptimizationTextContent   = EditorGUIUtility.TrTextContentWithIcon("Release mode disables C# debugging but improves C# performance.\nSwitching to release mode will recompile and reload all scripts.", EditorGUIUtility.GetHelpIcon(MessageType.Info));
                m_CodeOptimizationButtonContent = EditorGUIUtility.TrTextContent("Switch to release mode");
            }
            else
            {
                m_CodeOptimizationTitleContent  = EditorGUIUtility.TrTextContent("Mode: Release");
                m_CodeOptimizationTextContent   = EditorGUIUtility.TrTextContentWithIcon("Debug mode enables C# debugging but reduces C# performance.\nSwitching to debug mode will recompile and reload all scripts.", EditorGUIUtility.GetHelpIcon(MessageType.Info));
                m_CodeOptimizationButtonContent = EditorGUIUtility.TrTextContent("Switch to debug mode");
            }

            m_TextRectHeight = EditorStyles.helpBox.CalcHeight(m_CodeOptimizationTextContent, k_WindowWidth);
            m_WindowStyle    = new GUIStyle {
                padding = new RectOffset(10, 10, 10, 10)
            };
        }
        public static void OnGUI()
        {
            GUILayout.Space(10f);
            if (!InternalEditorUtility.HasTeamLicense())
            {
                GUILayout.Label(EditorGUIUtility.TempContent("You need to have a Pro or Team license to use the cache server.", EditorGUIUtility.GetHelpIcon(MessageType.Warning)), EditorStyles.helpBox, new GUILayoutOption[0]);
            }
            EditorGUI.BeginDisabledGroup(!InternalEditorUtility.HasTeamLicense());
            if (!CacheServerPreferences.s_PrefsLoaded)
            {
                CacheServerPreferences.ReadPreferences();
                CacheServerPreferences.s_PrefsLoaded = true;
            }
            if (CacheServerPreferences.s_CacheServerEnabled && CacheServerPreferences.s_ConnectionState == CacheServerPreferences.ConnectionState.Unknown)
            {
                if (InternalEditorUtility.CanConnectToCacheServer())
                {
                    CacheServerPreferences.s_ConnectionState = CacheServerPreferences.ConnectionState.Success;
                }
                else
                {
                    CacheServerPreferences.s_ConnectionState = CacheServerPreferences.ConnectionState.Failure;
                }
            }
            EditorGUI.BeginChangeCheck();
            CacheServerPreferences.s_CacheServerEnabled = EditorGUILayout.Toggle("Use Cache Server", CacheServerPreferences.s_CacheServerEnabled, new GUILayoutOption[0]);
            EditorGUI.BeginDisabledGroup(!CacheServerPreferences.s_CacheServerEnabled);
            CacheServerPreferences.s_CacheServerIPAddress = EditorGUILayout.TextField("IP Address", CacheServerPreferences.s_CacheServerIPAddress, new GUILayoutOption[0]);
            if (GUI.changed)
            {
                CacheServerPreferences.s_ConnectionState = CacheServerPreferences.ConnectionState.Unknown;
            }
            GUILayout.Space(5f);
            if (GUILayout.Button("Check Connection", new GUILayoutOption[]
            {
                GUILayout.Width(150f)
            }))
            {
                if (InternalEditorUtility.CanConnectToCacheServer())
                {
                    CacheServerPreferences.s_ConnectionState = CacheServerPreferences.ConnectionState.Success;
                }
                else
                {
                    CacheServerPreferences.s_ConnectionState = CacheServerPreferences.ConnectionState.Failure;
                }
            }
            GUILayout.Space(-25f);
            switch (CacheServerPreferences.s_ConnectionState)
            {
            case CacheServerPreferences.ConnectionState.Unknown:
                GUILayout.Space(44f);
                break;

            case CacheServerPreferences.ConnectionState.Success:
                EditorGUILayout.HelpBox("Connection successful.", MessageType.Info, false);
                break;

            case CacheServerPreferences.ConnectionState.Failure:
                EditorGUILayout.HelpBox("Connection failed.", MessageType.Warning, false);
                break;
            }
            EditorGUI.EndDisabledGroup();
            if (EditorGUI.EndChangeCheck())
            {
                CacheServerPreferences.WritePreferences();
                CacheServerPreferences.ReadPreferences();
            }
            EditorGUI.EndDisabledGroup();
        }
        private static void OnGUI(string searchContext)
        {
            EditorGUIUtility.labelWidth = 200f;
            // Get event type before the event is used.
            var eventType = Event.current.type;

            if (!InternalEditorUtility.HasTeamLicense())
            {
                GUILayout.Label(EditorGUIUtility.TempContent("You need to have a Pro or Team license to use the cache server.", EditorGUIUtility.GetHelpIcon(MessageType.Warning)), EditorStyles.helpBox);
            }


            using (new EditorGUI.DisabledScope(!InternalEditorUtility.HasTeamLicense()))
            {
                if (!s_PrefsLoaded)
                {
                    ReadPreferences();

                    if (s_CacheServerMode != CacheServerMode.Disabled && s_ConnectionState == ConnectionState.Unknown)
                    {
                        if (InternalEditorUtility.CanConnectToCacheServer())
                        {
                            s_ConnectionState = ConnectionState.Success;
                        }
                        else
                        {
                            s_ConnectionState = ConnectionState.Failure;
                        }
                    }

                    s_PrefsLoaded = true;
                }

                EditorGUI.BeginChangeCheck();

                var overrideAddress = GetCommandLineRemoteAddressOverride();

                if (overrideAddress != null)
                {
                    EditorGUILayout.HelpBox("Cache Server preferences cannot be modified because a remote address was specified via command line argument. To modify Cache Server preferences, restart Unity without the " + kIpAddressKeyArgs + " command line argument.", MessageType.Info, true);
                }

                using (new EditorGUI.DisabledScope(overrideAddress != null))
                {
                    var displayMode = overrideAddress != null ? CacheServerMode.Remote : s_CacheServerMode;
                    s_CacheServerMode = (CacheServerMode)EditorGUILayout.EnumPopup("Cache Server Mode", displayMode);
                }

                if (s_CacheServerMode == CacheServerMode.Remote)
                {
                    using (new EditorGUI.DisabledScope(overrideAddress != null))
                    {
                        var displayAddress = overrideAddress != null ? overrideAddress : s_CacheServerIPAddress;
                        s_CacheServerIPAddress = EditorGUILayout.DelayedTextField("IP Address", displayAddress);
                        if (GUI.changed)
                        {
                            s_ConnectionState = ConnectionState.Unknown;
                        }
                    }

                    GUILayout.Space(5);

                    if (GUILayout.Button("Check Connection", GUILayout.Width(150)))
                    {
                        if (InternalEditorUtility.CanConnectToCacheServer())
                        {
                            s_ConnectionState = ConnectionState.Success;
                        }
                        else
                        {
                            s_ConnectionState = ConnectionState.Failure;
                        }
                    }

                    GUILayout.Space(-25);
                    switch (s_ConnectionState)
                    {
                    case ConnectionState.Success:
                        EditorGUILayout.HelpBox("Connection successful.", MessageType.Info, false);
                        break;

                    case ConnectionState.Failure:
                        EditorGUILayout.HelpBox("Connection failed.", MessageType.Warning, false);
                        break;

                    case ConnectionState.Unknown:
                        GUILayout.Space(44);
                        break;
                    }
                }
                else if (s_CacheServerMode == CacheServerMode.Local)
                {
                    const int kMinSizeInGigabytes = 1;
                    const int kMaxSizeInGigabytes = 200;

                    // Write size in GigaBytes.
                    s_LocalCacheServerSize = EditorGUILayout.IntSlider(Properties.maxCacheSize, s_LocalCacheServerSize, kMinSizeInGigabytes, kMaxSizeInGigabytes);

                    s_EnableCustomPath = EditorGUILayout.Toggle(Properties.customCacheLocation, s_EnableCustomPath);
                    // browse for cache folder if not per project
                    if (s_EnableCustomPath)
                    {
                        GUIStyle style = EditorStyles.miniButton;
                        GUILayout.BeginHorizontal();
                        EditorGUILayout.PrefixLabel(Properties.cacheFolderLocation, style);
                        Rect       r       = GUILayoutUtility.GetRect(GUIContent.none, style);
                        GUIContent guiText = string.IsNullOrEmpty(s_CachePath) ? Properties.browse : new GUIContent(s_CachePath);
                        if (EditorGUI.DropdownButton(r, guiText, FocusType.Passive, style))
                        {
                            string pathToOpen = s_CachePath;
                            string path       = EditorUtility.OpenFolderPanel(Properties.browseCacheLocation.text, pathToOpen, "");
                            if (!string.IsNullOrEmpty(path))
                            {
                                if (LocalCacheServer.CheckValidCacheLocation(path))
                                {
                                    s_CachePath = path;
                                    WritePreferences();
                                }
                                else
                                {
                                    EditorUtility.DisplayDialog("Invalid Cache Location", string.Format("The directory {0} contains some files which don't look like Unity Cache server files. Please delete the directory contents or choose another directory.", path), "OK");
                                }
                                EditorGUIUtility.ExitGUI();
                            }
                        }
                        GUILayout.EndHorizontal();
                    }
                    else
                    {
                        s_CachePath = "";
                    }

                    bool locationExists = LocalCacheServer.CheckCacheLocationExists();
                    if (locationExists == true)
                    {
                        GUIContent cacheSizeIs = EditorGUIUtility.TrTextContent("Cache size is unknown");
                        if (s_LocalCacheServerUsedSize != -1)
                        {
                            cacheSizeIs = EditorGUIUtility.TextContent("Cache size is " + EditorUtility.FormatBytes(s_LocalCacheServerUsedSize));
                        }

                        GUILayout.BeginHorizontal();
                        GUIStyle style = EditorStyles.miniButton;
                        EditorGUILayout.PrefixLabel(cacheSizeIs, style);
                        Rect r = GUILayoutUtility.GetRect(GUIContent.none, style);
                        if (EditorGUI.Button(r, Properties.enumerateCache, style))
                        {
                            s_LocalCacheServerUsedSize = LocalCacheServer.CheckCacheLocationExists() ? FileUtil.GetDirectorySize(LocalCacheServer.GetCacheLocation()) : 0;
                        }
                        GUILayout.EndHorizontal();

                        GUILayout.BeginHorizontal();
                        GUIContent spacerContent = EditorGUIUtility.blankContent;
                        EditorGUILayout.PrefixLabel(spacerContent, style);
                        Rect r2 = GUILayoutUtility.GetRect(GUIContent.none, style);
                        if (EditorGUI.Button(r2, Properties.cleanCache, style))
                        {
                            LocalCacheServer.Clear();
                            s_LocalCacheServerUsedSize = 0;
                        }
                        GUILayout.EndHorizontal();
                    }
                    else
                    {
                        EditorGUILayout.HelpBox("Local cache directory does not exist - please check that you can access the cache folder and are able to write to it", MessageType.Warning, false);
                        //If the cache server was on an external HDD or on a temporarily unavailable network drive, set the size to unknown so that the user re-queries it when they've reconnected
                        s_LocalCacheServerUsedSize = -1;
                    }

                    GUILayout.Label(Properties.cacheFolderLocation.text + ":");
                    GUILayout.Label(LocalCacheServer.GetCacheLocation(), Styles.cacheFolderLocation);
                }

                if (EditorGUI.EndChangeCheck())
                {
                    s_HasPendingChanges = true;
                }

                // Only commit changes when we don't have an active hot control, to avoid restarting the cache server all the time while the slider is dragged, slowing down the UI.
                if (s_HasPendingChanges && GUIUtility.hotControl == 0)
                {
                    s_HasPendingChanges = false;
                    WritePreferences();
                    ReadPreferences();
                }
            }
        }
        public static void OnGUI()
        {
            EventType type = Event.current.type;

            if (s_Constants == null)
            {
                s_Constants = new Constants();
            }
            GUILayout.Space(10f);
            if (!InternalEditorUtility.HasTeamLicense())
            {
                GUILayout.Label(EditorGUIUtility.TempContent("You need to have a Pro or Team license to use the cache server.", EditorGUIUtility.GetHelpIcon(MessageType.Warning)), EditorStyles.helpBox, new GUILayoutOption[0]);
            }
            using (new EditorGUI.DisabledScope(!InternalEditorUtility.HasTeamLicense()))
            {
                if (!s_PrefsLoaded)
                {
                    ReadPreferences();
                    if ((s_CacheServerMode != CacheServerMode.Disabled) && (s_ConnectionState == ConnectionState.Unknown))
                    {
                        if (InternalEditorUtility.CanConnectToCacheServer())
                        {
                            s_ConnectionState = ConnectionState.Success;
                        }
                        else
                        {
                            s_ConnectionState = ConnectionState.Failure;
                        }
                    }
                    s_PrefsLoaded = true;
                }
                EditorGUI.BeginChangeCheck();
                if (Collab.instance.collabInfo.whitelisted && IsCollabCacheEnabled())
                {
                    s_CollabCacheEnabled = EditorGUILayout.Toggle("Use Collab Cache", s_CollabCacheEnabled, new GUILayoutOption[0]);
                    using (new EditorGUI.DisabledScope(!s_CollabCacheEnabled))
                    {
                        s_CollabCacheIPAddress = EditorGUILayout.TextField("Collab Cache IP Address", s_CollabCacheIPAddress, new GUILayoutOption[0]);
                    }
                }
                s_CacheServerMode = (CacheServerMode)EditorGUILayout.EnumPopup("Cache Server Mode", s_CacheServerMode, new GUILayoutOption[0]);
                if (s_CacheServerMode != CacheServerMode.Remote)
                {
                    goto Label_0238;
                }
                s_CacheServerIPAddress = EditorGUILayout.DelayedTextField("IP Address", s_CacheServerIPAddress, new GUILayoutOption[0]);
                if (GUI.changed)
                {
                    s_ConnectionState = ConnectionState.Unknown;
                }
                GUILayout.Space(5f);
                GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.Width(150f) };
                if (GUILayout.Button("Check Connection", options))
                {
                    if (InternalEditorUtility.CanConnectToCacheServer())
                    {
                        s_ConnectionState = ConnectionState.Success;
                    }
                    else
                    {
                        s_ConnectionState = ConnectionState.Failure;
                    }
                }
                GUILayout.Space(-25f);
                ConnectionState state = s_ConnectionState;
                if (state != ConnectionState.Success)
                {
                    if (state == ConnectionState.Failure)
                    {
                        goto Label_0212;
                    }
                    if (state == ConnectionState.Unknown)
                    {
                        goto Label_0223;
                    }
                }
                else
                {
                    EditorGUILayout.HelpBox("Connection successful.", MessageType.Info, false);
                }
                goto Label_04B9;
Label_0212:
                EditorGUILayout.HelpBox("Connection failed.", MessageType.Warning, false);
                goto Label_04B9;
Label_0223:
                GUILayout.Space(44f);
                goto Label_04B9;
Label_0238:
                if (s_CacheServerMode == CacheServerMode.Local)
                {
                    s_LocalCacheServerSize = EditorGUILayout.IntSlider(Styles.maxCacheSize, s_LocalCacheServerSize, 1, 200, new GUILayoutOption[0]);
                    s_EnableCustomPath     = EditorGUILayout.Toggle(Styles.customCacheLocation, s_EnableCustomPath, new GUILayoutOption[0]);
                    if (s_EnableCustomPath)
                    {
                        GUIStyle popup = EditorStyles.popup;
                        GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                        EditorGUILayout.PrefixLabel(Styles.cacheFolderLocation, popup);
                        Rect       position = GUILayoutUtility.GetRect(GUIContent.none, popup);
                        GUIContent content  = !string.IsNullOrEmpty(s_CachePath) ? new GUIContent(s_CachePath) : Styles.browse;
                        if (EditorGUI.ButtonMouseDown(position, content, FocusType.Passive, popup))
                        {
                            string folder = s_CachePath;
                            string str2   = EditorUtility.OpenFolderPanel(Styles.browseCacheLocation.text, folder, "");
                            if (!string.IsNullOrEmpty(str2))
                            {
                                if (LocalCacheServer.CheckValidCacheLocation(str2))
                                {
                                    s_CachePath = str2;
                                    WritePreferences();
                                }
                                else
                                {
                                    EditorUtility.DisplayDialog("Invalid Cache Location", "The directory " + str2 + " contains some files which don't look like Unity Cache server files. Please delete the directory contents or choose another directory.", "OK");
                                }
                            }
                        }
                        GUILayout.EndHorizontal();
                    }
                    else
                    {
                        s_CachePath = "";
                    }
                    if (LocalCacheServer.CheckCacheLocationExists())
                    {
                        GUIContent label = EditorGUIUtility.TextContent("Cache size is unknown");
                        if (s_LocalCacheServerUsedSize != -1L)
                        {
                            label = EditorGUIUtility.TextContent("Cache size is " + EditorUtility.FormatBytes(s_LocalCacheServerUsedSize));
                        }
                        GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                        GUIStyle miniButton = EditorStyles.miniButton;
                        EditorGUILayout.PrefixLabel(label, miniButton);
                        if (EditorGUI.Button(GUILayoutUtility.GetRect(GUIContent.none, miniButton), Styles.enumerateCache, miniButton))
                        {
                            s_LocalCacheServerUsedSize = !LocalCacheServer.CheckCacheLocationExists() ? 0L : FileUtil.GetDirectorySize(LocalCacheServer.GetCacheLocation());
                        }
                        GUILayout.EndHorizontal();
                        GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                        EditorGUILayout.PrefixLabel(EditorGUIUtility.blankContent, miniButton);
                        if (EditorGUI.Button(GUILayoutUtility.GetRect(GUIContent.none, miniButton), Styles.cleanCache, miniButton))
                        {
                            LocalCacheServer.Clear();
                            s_LocalCacheServerUsedSize = 0L;
                        }
                        GUILayout.EndHorizontal();
                    }
                    else
                    {
                        EditorGUILayout.HelpBox("Local cache directory does not exist - please check that you can access the cache folder and are able to write to it", MessageType.Warning, false);
                        s_LocalCacheServerUsedSize = -1L;
                    }
                    GUILayout.Label(Styles.cacheFolderLocation.text + ":", new GUILayoutOption[0]);
                    GUILayout.Label(LocalCacheServer.GetCacheLocation(), s_Constants.cacheFolderLocation, new GUILayoutOption[0]);
                }
Label_04B9:
                if (EditorGUI.EndChangeCheck())
                {
                    s_HasPendingChanges = true;
                }
                if (s_HasPendingChanges && (GUIUtility.hotControl == 0))
                {
                    s_HasPendingChanges = false;
                    WritePreferences();
                    ReadPreferences();
                }
            }
        }
 public override void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor)
 {
     if (prop.type != MaterialProperty.PropType.Float && prop.type != MaterialProperty.PropType.Range)
     {
         GUIContent label1 = EditorGUIUtility.TempContent("Enum used on a non-float property: " + prop.name, (Texture)EditorGUIUtility.GetHelpIcon(MessageType.Warning));
         EditorGUI.LabelField(position, label1, EditorStyles.helpBox);
     }
     else
     {
         EditorGUI.BeginChangeCheck();
         EditorGUI.showMixedValue = prop.hasMixedValue;
         int floatValue = (int)prop.floatValue;
         int num        = EditorGUI.IntPopup(position, label, floatValue, this.names, this.values);
         EditorGUI.showMixedValue = false;
         if (!EditorGUI.EndChangeCheck())
         {
             return;
         }
         prop.floatValue = (float)num;
     }
 }
        public static void OnGUI()
        {
            EventType type = Event.current.type;

            if (CacheServerPreferences.s_Constants == null)
            {
                CacheServerPreferences.s_Constants = new CacheServerPreferences.Constants();
            }
            GUILayout.Space(10f);
            if (!InternalEditorUtility.HasTeamLicense())
            {
                GUILayout.Label(EditorGUIUtility.TempContent("You need to have a Pro or Team license to use the cache server.", EditorGUIUtility.GetHelpIcon(MessageType.Warning)), EditorStyles.helpBox, new GUILayoutOption[0]);
            }
            using (new EditorGUI.DisabledScope(!InternalEditorUtility.HasTeamLicense()))
            {
                if (!CacheServerPreferences.s_PrefsLoaded)
                {
                    CacheServerPreferences.ReadPreferences();
                    if (CacheServerPreferences.s_CacheServerMode != CacheServerPreferences.CacheServerMode.Disabled && CacheServerPreferences.s_ConnectionState == CacheServerPreferences.ConnectionState.Unknown)
                    {
                        if (InternalEditorUtility.CanConnectToCacheServer())
                        {
                            CacheServerPreferences.s_ConnectionState = CacheServerPreferences.ConnectionState.Success;
                        }
                        else
                        {
                            CacheServerPreferences.s_ConnectionState = CacheServerPreferences.ConnectionState.Failure;
                        }
                    }
                    CacheServerPreferences.s_PrefsLoaded = true;
                }
                EditorGUI.BeginChangeCheck();
                if (Collab.instance.collabInfo.whitelisted && CacheServerPreferences.IsCollabCacheEnabled())
                {
                    CacheServerPreferences.s_CollabCacheEnabled = EditorGUILayout.Toggle("Use Collab Cache", CacheServerPreferences.s_CollabCacheEnabled, new GUILayoutOption[0]);
                    using (new EditorGUI.DisabledScope(!CacheServerPreferences.s_CollabCacheEnabled))
                    {
                        CacheServerPreferences.s_CollabCacheIPAddress = EditorGUILayout.TextField("Collab Cache IP Address", CacheServerPreferences.s_CollabCacheIPAddress, new GUILayoutOption[0]);
                    }
                }
                CacheServerPreferences.s_CacheServerMode = (CacheServerPreferences.CacheServerMode)EditorGUILayout.EnumPopup("Cache Server Mode", CacheServerPreferences.s_CacheServerMode, new GUILayoutOption[0]);
                if (CacheServerPreferences.s_CacheServerMode == CacheServerPreferences.CacheServerMode.Remote)
                {
                    CacheServerPreferences.s_CacheServerIPAddress = EditorGUILayout.DelayedTextField("IP Address", CacheServerPreferences.s_CacheServerIPAddress, new GUILayoutOption[0]);
                    if (GUI.changed)
                    {
                        CacheServerPreferences.s_ConnectionState = CacheServerPreferences.ConnectionState.Unknown;
                    }
                    GUILayout.Space(5f);
                    if (GUILayout.Button("Check Connection", new GUILayoutOption[]
                    {
                        GUILayout.Width(150f)
                    }))
                    {
                        if (InternalEditorUtility.CanConnectToCacheServer())
                        {
                            CacheServerPreferences.s_ConnectionState = CacheServerPreferences.ConnectionState.Success;
                        }
                        else
                        {
                            CacheServerPreferences.s_ConnectionState = CacheServerPreferences.ConnectionState.Failure;
                        }
                    }
                    GUILayout.Space(-25f);
                    CacheServerPreferences.ConnectionState connectionState = CacheServerPreferences.s_ConnectionState;
                    if (connectionState != CacheServerPreferences.ConnectionState.Success)
                    {
                        if (connectionState != CacheServerPreferences.ConnectionState.Failure)
                        {
                            if (connectionState == CacheServerPreferences.ConnectionState.Unknown)
                            {
                                GUILayout.Space(44f);
                            }
                        }
                        else
                        {
                            EditorGUILayout.HelpBox("Connection failed.", MessageType.Warning, false);
                        }
                    }
                    else
                    {
                        EditorGUILayout.HelpBox("Connection successful.", MessageType.Info, false);
                    }
                }
                else if (CacheServerPreferences.s_CacheServerMode == CacheServerPreferences.CacheServerMode.Local)
                {
                    CacheServerPreferences.s_LocalCacheServerSize = EditorGUILayout.IntSlider(CacheServerPreferences.Styles.maxCacheSize, CacheServerPreferences.s_LocalCacheServerSize, 1, 200, new GUILayoutOption[0]);
                    CacheServerPreferences.s_EnableCustomPath     = EditorGUILayout.Toggle(CacheServerPreferences.Styles.customCacheLocation, CacheServerPreferences.s_EnableCustomPath, new GUILayoutOption[0]);
                    if (CacheServerPreferences.s_EnableCustomPath)
                    {
                        GUIStyle popup = EditorStyles.popup;
                        GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                        EditorGUILayout.PrefixLabel(CacheServerPreferences.Styles.cacheFolderLocation, popup);
                        Rect       rect    = GUILayoutUtility.GetRect(GUIContent.none, popup);
                        GUIContent content = (!string.IsNullOrEmpty(CacheServerPreferences.s_CachePath)) ? new GUIContent(CacheServerPreferences.s_CachePath) : CacheServerPreferences.Styles.browse;
                        if (EditorGUI.ButtonMouseDown(rect, content, FocusType.Passive, popup))
                        {
                            string folder = CacheServerPreferences.s_CachePath;
                            string text   = EditorUtility.OpenFolderPanel(CacheServerPreferences.Styles.browseCacheLocation.text, folder, "");
                            if (!string.IsNullOrEmpty(text))
                            {
                                if (LocalCacheServer.CheckValidCacheLocation(text))
                                {
                                    CacheServerPreferences.s_CachePath = text;
                                    CacheServerPreferences.WritePreferences();
                                }
                                else
                                {
                                    EditorUtility.DisplayDialog("Invalid Cache Location", "The directory " + text + " contains some files which don't look like Unity Cache server files. Please delete the directory contents or choose another directory.", "OK");
                                }
                            }
                        }
                        GUILayout.EndHorizontal();
                    }
                    else
                    {
                        CacheServerPreferences.s_CachePath = "";
                    }
                    if (GUILayout.Button(CacheServerPreferences.Styles.cleanCache, new GUILayoutOption[]
                    {
                        GUILayout.Width(120f)
                    }))
                    {
                        LocalCacheServer.Clear();
                        CacheServerPreferences.s_LocalCacheServerUsedSize = 0L;
                    }
                    if (CacheServerPreferences.s_LocalCacheServerUsedSize == -1L)
                    {
                        CacheServerPreferences.s_LocalCacheServerUsedSize = FileUtil.GetDirectorySize(LocalCacheServer.GetCacheLocation());
                    }
                    GUILayout.Label(CacheServerPreferences.Styles.cacheSizeIs.text + " " + EditorUtility.FormatBytes(CacheServerPreferences.s_LocalCacheServerUsedSize), new GUILayoutOption[0]);
                    GUILayout.Label(CacheServerPreferences.Styles.cacheFolderLocation.text + ":", new GUILayoutOption[0]);
                    GUILayout.Label(LocalCacheServer.GetCacheLocation(), CacheServerPreferences.s_Constants.cacheFolderLocation, new GUILayoutOption[0]);
                }
                if (EditorGUI.EndChangeCheck())
                {
                    CacheServerPreferences.s_HasPendingChanges = true;
                }
                if ((CacheServerPreferences.s_HasPendingChanges && type == EventType.MouseUp) || type == EventType.KeyDown)
                {
                    CacheServerPreferences.WritePreferences();
                    CacheServerPreferences.ReadPreferences();
                    CacheServerPreferences.s_HasPendingChanges = false;
                }
            }
        }
        public override void OnGUI(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor)
        {
            if (!MaterialKeywordEnumDrawer.IsPropertyTypeSuitable(prop))
            {
                GUIContent label2 = EditorGUIUtility.TempContent("KeywordEnum used on a non-float property: " + prop.name, EditorGUIUtility.GetHelpIcon(MessageType.Warning));
                EditorGUI.LabelField(position, label2, EditorStyles.helpBox);
                return;
            }
            EditorGUI.BeginChangeCheck();
            EditorGUI.showMixedValue = prop.hasMixedValue;
            int num = (int)prop.floatValue;

            num = EditorGUI.Popup(position, label, num, this.keywords);
            EditorGUI.showMixedValue = false;
            if (EditorGUI.EndChangeCheck())
            {
                prop.floatValue = (float)num;
                this.SetKeyword(prop, num);
            }
        }
 public override void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor)
 {
     if (!MaterialToggleDrawer.IsPropertyTypeSuitable(prop))
     {
         GUIContent label1 = EditorGUIUtility.TempContent("Toggle used on a non-float property: " + prop.name, (Texture)EditorGUIUtility.GetHelpIcon(MessageType.Warning));
         EditorGUI.LabelField(position, label1, EditorStyles.helpBox);
     }
     else
     {
         EditorGUI.BeginChangeCheck();
         bool flag = (double)Math.Abs(prop.floatValue) > 1.0 / 1000.0;
         EditorGUI.showMixedValue = prop.hasMixedValue;
         bool on = EditorGUI.Toggle(position, label, flag);
         EditorGUI.showMixedValue = false;
         if (!EditorGUI.EndChangeCheck())
         {
             return;
         }
         prop.floatValue = !on ? 0.0f : 1f;
         this.SetKeyword(prop, on);
     }
 }