Example #1
1
        private static bool ShowButtons(SerializedProperty _list, int _index)
        {
            EditorGUILayout.BeginHorizontal();
            {
                if (GUILayout.Button(moveUpBtn, EditorStyles.miniButton))
                {
                    _list.MoveArrayElement(_index, _index - 1);
                    return true;
                }

                if (GUILayout.Button(moveDnBtn, EditorStyles.miniButton))
                {
                    _list.MoveArrayElement(_index, _index + 1);
                    return true;
                }

                if (GUILayout.Button(deleteBtn, EditorStyles.miniButton))
                {
                    _list.DeleteArrayElementAtIndex(_index);
                    return true;
                }

                if (GUILayout.Button(dupeBtn, EditorStyles.miniButton))
                {
                    AddNewArrayElement(_list, _index);
                    return true;
                }
            }
            EditorGUILayout.EndHorizontal();

            return false;
        }
Example #2
0
 public void AttackPatternField(SerializedProperty attackPatterns)
 {
     Vector3 moveRemove = new Vector3(-1f, -1f, 0f);
     int c = attackPatterns.FindPropertyRelative ("Array.size").intValue;
     if(c < 1)
     {
         attackPatterns.InsertArrayElementAtIndex(0);
         attackPatterns.GetArrayElementAtIndex(0).objectReferenceValue = gameObject.GetComponent<AbstractAttackPattern>();
     }
     for(int i = 0; i < c; i++)
     {
         EditorGUILayout.BeginHorizontal();
         SerializedProperty arrayElement = attackPatterns.GetArrayElementAtIndex(i);
         AbstractAttackPattern ap = (AbstractAttackPattern)arrayElement.objectReferenceValue;
         EditorGUILayout.PropertyField(arrayElement, new GUIContent((ap != null) ? GetAttackPatternName(ap) : i.ToString()));
         moveRemove = DanmakuEditorUtils.UpDownRemoveButtons(moveRemove, c, i, false);
         EditorGUILayout.EndHorizontal();
     }
     if (moveRemove.y >= 0)
     {
         int removeIndex = (int)moveRemove.y;
         if(attackPatterns.GetArrayElementAtIndex(removeIndex).objectReferenceValue != null)
         {
             attackPatterns.DeleteArrayElementAtIndex(removeIndex);
         }
         attackPatterns.DeleteArrayElementAtIndex(removeIndex);
     }
     if (moveRemove.x >= 0)
     {
         int moveIndex = (int)moveRemove.x;
         if (moveRemove.z > 0)
         {
             attackPatterns.MoveArrayElement (moveIndex, moveIndex + 1);
         }
         if (moveRemove.z < 0)
         {
             attackPatterns.MoveArrayElement (moveIndex, moveIndex - 1);
         }
     }
     if (GUILayout.Button("Add"))
     {
         attackPatterns.InsertArrayElementAtIndex(c);
     }
 }
Example #3
0
 static void ShowButtons(SerializedProperty list, int index)
 {
     if (GUILayout.Button(moveButtonContent, EditorStyles.miniButtonLeft, miniButtonWidth)) {
         list.MoveArrayElement(index, index + 1);
     }
     if (GUILayout.Button(duplicateButtonContent, EditorStyles.miniButtonMid, miniButtonWidth)) {
         list.InsertArrayElementAtIndex(index);
     }
     if (GUILayout.Button(deleteButtonContent, EditorStyles.miniButtonRight, miniButtonWidth)) {
         int oldSize = list.arraySize;
         list.DeleteArrayElementAtIndex(index);
         if (list.arraySize == oldSize) {
             list.DeleteArrayElementAtIndex(index);
         }
     }
 }
 public static void DrawList(ref Rect position, SerializedProperty property)
 {
     position.height = 16;
     EditorGUI.PropertyField (position, property);
     position.y += 18;
     EditorGUI.indentLevel++;
     if (property.isExpanded) {
         Rect buttonPosition;
         for (int i = 0; i < property.arraySize; i++) {
             buttonPosition = position;
             buttonPosition.height = 16;
             buttonPosition.width = 20;
             buttonPosition.x += position.width - 62;
             if (GUI.Button (buttonPosition, moveButtonContent, EditorStyles.miniButtonLeft)) {
                 property.MoveArrayElement (i, i + 1);
             }
             buttonPosition.x += 20;
             if (GUI.Button (buttonPosition, duplicateButtonContent, EditorStyles.miniButtonMid)) {
                 property.InsertArrayElementAtIndex (i);
             }
             buttonPosition.x += 20;
             if (GUI.Button (buttonPosition, deleteButtonContent, EditorStyles.miniButtonRight)) {
                 int oldsize = property.arraySize;
                 property.DeleteArrayElementAtIndex (i);
                 if (oldsize == property.arraySize) {
                     property.DeleteArrayElementAtIndex (i);
                 }
             } else {
                 DrawProperty (ref position, property.GetArrayElementAtIndex (i), true);
             }
         }
         buttonPosition = position;
         buttonPosition.height = 16;
         buttonPosition.width -= EditorGUI.indentLevel * 16;
         buttonPosition.x += EditorGUI.indentLevel * 16;
         if (GUI.Button (buttonPosition, addButtonContent, EditorStyles.miniButton)) {
             property.arraySize += 1;
         }
         position.y += 18;
     }
     EditorGUI.indentLevel--;
 }
        //private static Color _oldColor;
        private static bool ShowButtons(Rect position, SerializedProperty property, int index)
        {
            var result = false;

            var pos = new Rect(position);
            pos.y += 4;

            if (GUI.Button(pos, GuiContentCache.Instance.EditSelector, StyleCache.Instance.ImageOnlyNoFrameButton)) // EditorStyles.miniButtonMid
            {
                //EditorUtility.DisplayDialog("Editing selector", "Not implemented.", "Close");
                SerializedProperty declaration = property.GetArrayElementAtIndex(index);
                EditStyleDeclarationCommand.Execute(declaration);
            }

            pos.x += ButtonWidth;
            if (GUI.Button(pos, GuiContentCache.Instance.Duplicate, StyleCache.Instance.ImageOnlyNoFrameButton)) // EditorStyles.miniButtonMid
            {
                bool expanded = property.GetArrayElementAtIndex(index).isExpanded;
                property.InsertArrayElementAtIndex(index);
                SerializedProperty newItem = property.GetArrayElementAtIndex(index);
                newItem.Reset();
                newItem.isExpanded = expanded;
            }
            
            pos.x += ButtonWidth;
            if (GUI.Button(pos, GuiContentCache.Instance.Delete, StyleCache.Instance.ImageOnlyNoFrameButton)) // EditorStyles.miniButtonRight
            {
                if (EditorUtility.DisplayDialog("Confirmation", "Are you sure you want to remove this style declaration?", "OK", "Cancel"))
                    result = true;
            }

            // move buttons

            if (index == 0)
                GUI.enabled = false;

            pos.x += ButtonWidth;
            if (GUI.Button(pos, GuiContentCache.Instance.MoveUp, StyleCache.Instance.ImageOnlyNoFrameButton)) // EditorStyles.miniButtonLeft
            {
                if (index > 0)
                {
                    bool expanded1 = property.GetArrayElementAtIndex(index).isExpanded;
                    bool expanded2 = property.GetArrayElementAtIndex(index - 1).isExpanded;
                    property.MoveArrayElement(index, index - 1);
                    property.GetArrayElementAtIndex(index).isExpanded = expanded1;
                    property.GetArrayElementAtIndex(index - 1).isExpanded = expanded2;

                    ShouldProcessStyles = true;
                }
            }
            pos.x += ButtonWidth;

            if (index == 0)
                GUI.enabled = true;

            if (index == _size - 1)
                GUI.enabled = false;

            if (GUI.Button(pos, GuiContentCache.Instance.MoveDown, StyleCache.Instance.ImageOnlyNoFrameButton)) // EditorStyles.miniButtonLeft
            {
                bool expanded1 = property.GetArrayElementAtIndex(index).isExpanded;
                bool expanded2 = property.GetArrayElementAtIndex(index + 1).isExpanded;
                property.MoveArrayElement(index, index + 1);
                property.GetArrayElementAtIndex(index).isExpanded = expanded1;
                property.GetArrayElementAtIndex(index + 1).isExpanded = expanded2;

                ShouldProcessStyles = true;
            }

            if (index == _size - 1)
                GUI.enabled = true;

            pos.x += ButtonWidth;

            return result;
        }
 public static void DrawListLayout(SerializedProperty property)
 {
     EditorGUILayout.PropertyField (property);
     EditorGUI.indentLevel++;
     if (property.isExpanded) {
         for (int i = 0; i < property.arraySize; i++) {
             EditorGUILayout.BeginHorizontal ();
             EditorGUILayout.PropertyField (property.GetArrayElementAtIndex (i), true);
             if (GUILayout.Button (moveButtonContent, EditorStyles.miniButtonLeft, GUILayout.Width(20))) {
                 property.MoveArrayElement (i, i + 1);
             }
             if (GUILayout.Button (duplicateButtonContent, EditorStyles.miniButtonMid, GUILayout.Width(20))) {
                 property.InsertArrayElementAtIndex (i);
             }
             if (GUILayout.Button (deleteButtonContent, EditorStyles.miniButtonRight, GUILayout.Width(20))) {
                 int oldsize = property.arraySize;
                 property.DeleteArrayElementAtIndex (i);
                 if (oldsize == property.arraySize) {
                     property.DeleteArrayElementAtIndex (i);
                 }
             }
             EditorGUILayout.EndHorizontal ();
         }
         if (GUILayout.Button (addButtonContent, EditorStyles.miniButton)) {
             property.arraySize += 1;
         }
     }
     EditorGUI.indentLevel--;
 }
		private static bool ShowButtons(Rect position, SerializedProperty property, int index)
		{
			var result = false;

			var pos = new Rect(position);
			pos.y -= 4;

			if (GUI.Button(pos, GuiContentCache.Instance.Delete, StyleCache.Instance.ImageOnlyNoFrameButton)) // EditorStyles.miniButtonRight
			{
				result = true; // removed //property.DeleteArrayElementAtIndex(index);
			}

			// move buttons

			if (index == 0)
				GUI.enabled = false;

			pos.x += ButtonWidth;
			if (GUI.Button(pos, GuiContentCache.Instance.MoveUp, StyleCache.Instance.ImageOnlyNoFrameButton)) // EditorStyles.miniButtonLeft
			{
				if (index > 0)
				{
					bool expanded1 = property.GetArrayElementAtIndex(index).isExpanded;
					bool expanded2 = property.GetArrayElementAtIndex(index - 1).isExpanded;
					property.MoveArrayElement(index, index - 1);
					property.GetArrayElementAtIndex(index).isExpanded = expanded1;
					property.GetArrayElementAtIndex(index - 1).isExpanded = expanded2;
				}
			}
			pos.x += ButtonWidth;

			if (index == 0)
				GUI.enabled = true;

			if (index == _size - 1)
				GUI.enabled = false;

			if (GUI.Button(pos, GuiContentCache.Instance.MoveDown, StyleCache.Instance.ImageOnlyNoFrameButton)) // EditorStyles.miniButtonLeft
			{
				bool expanded1 = property.GetArrayElementAtIndex(index).isExpanded;
				bool expanded2 = property.GetArrayElementAtIndex(index + 1).isExpanded;
				property.MoveArrayElement(index, index + 1);
				property.GetArrayElementAtIndex(index).isExpanded = expanded1;
				property.GetArrayElementAtIndex(index + 1).isExpanded = expanded2;
			}

			if (index == _size - 1)
				GUI.enabled = true;

			pos.x += ButtonWidth;

			//GUI.color = _oldColor;

			return result;
		}
Example #8
0
		public static void AddArray(SerializedProperty prop, GUIContent guiContent, bool editHierarchy, bool changeOrder, DrawArrayElement drawArrayElement = null, OnAddToArray onAddToArray = null, DrawArrayElementLabel drawArrayElementLabel = null, bool showHeading = true) {
			int resetIndent = EditorGUI.indentLevel;

			// Array heading
			if (showHeading) {
				GUILayout.BeginHorizontal();
				GUILayout.Space(EditorGUI.indentLevel * indent);
				
				if (drawArrayElement == null) {
					GUILayout.Label(guiContent.text + " (" + prop.arraySize.ToString() + ")", GUILayout.Width(150));
				} else {
					EditorGUILayout.PropertyField(prop, new GUIContent(guiContent.text + " (" + prop.arraySize.ToString() + ")", string.Empty), false, GUILayout.Width(150));
				}
				
				GUILayout.EndHorizontal();
			}
			
			int deleteIndex = -1;
			
			if (drawArrayElement == null || !showHeading) prop.isExpanded = true;
			
			// Draw Array elements
			if (prop.isExpanded) {			
				for(int i = 0; i < prop.arraySize; i++) {
					GUILayout.BeginHorizontal(); // Main
					GUILayout.Space(((EditorGUI.indentLevel + 1) * indent));
					GUILayout.BeginVertical();
					
					element = prop.GetArrayElementAtIndex(i);

					// Label
					GUILayout.BeginHorizontal(); 
				
					if (editHierarchy && GUILayout.Button(new GUIContent("-", "Remove"), changeOrder? EditorStyles.miniButtonLeft: EditorStyles.miniButton, GUILayout.Width(20))){
						deleteIndex = i;
					}
					
					if (changeOrder) {
						if (GUILayout.Button(new GUIContent("<", "Move up"), editHierarchy? EditorStyles.miniButtonMid: EditorStyles.miniButtonLeft, GUILayout.Width(20))) {
							int moveTo = i == 0? prop.arraySize - 1: i - 1;
							prop.MoveArrayElement(i, moveTo);
							prop.isExpanded = true;
						}
							
						if (GUILayout.Button(new GUIContent(">", "Move down"), EditorStyles.miniButtonRight, GUILayout.Width(20))) {
							int moveTo = i == prop.arraySize - 1? 0: i + 1;
							prop.MoveArrayElement(i, moveTo);
							prop.isExpanded = true;
						}
					}
					
					// Calling the DrawArrayElementLabel delegate
					if (drawArrayElementLabel != null) {
						drawArrayElementLabel(element, editHierarchy);
					}
					
					GUILayout.EndHorizontal(); // End Label
					
					// Array Element
					GUILayout.BeginVertical();
					if (element.isExpanded && drawArrayElement != null) {
						drawArrayElement(element, editHierarchy);
					}
					GUILayout.EndVertical();
					
					GUILayout.Space(5);
					
					GUILayout.EndVertical(); // End Style
					GUILayout.EndHorizontal(); // End Main
				}
				
				// Deleting array elements
				if (deleteIndex != -1) prop.DeleteArrayElementAtIndex(deleteIndex);
				
				// Adding array elements
				GUILayout.BeginHorizontal();
				GUILayout.Space(((EditorGUI.indentLevel + 1) * indent) + 4);
				GUILayout.BeginVertical();
				
				if (editHierarchy && GUILayout.Button(new GUIContent("+", "Add"), EditorStyles.miniButton, GUILayout.Width(20))) {
					prop.arraySize ++;
					
					if (onAddToArray != null) onAddToArray(prop.GetArrayElementAtIndex(prop.arraySize - 1));
				}
				
				GUILayout.EndVertical();
				GUILayout.EndHorizontal();
			}
				
			EditorGUI.indentLevel = resetIndent;
		}
        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();

            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 blendWeightsProperty                    = currentSettings.FindPropertyRelative("blendWeights");
            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 resolutionScalingFixedDPIFactorProperty = currentSettings.FindPropertyRelative("resolutionScalingFixedDPIFactor");

            bool usingSRP = GraphicsSettings.renderPipelineAsset != null;

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

            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);
            if (!usingSRP)
            {
                EditorGUILayout.PropertyField(pixelLightCountProperty);
            }

            // still valid with SRP
            EditorGUILayout.PropertyField(textureQualityProperty);
            EditorGUILayout.PropertyField(anisotropicTexturesProperty);

            if (!usingSRP)
            {
                EditorGUILayout.PropertyField(antiAliasingProperty);
                EditorGUILayout.PropertyField(softParticlesProperty);
                if (softParticlesProperty.boolValue)
                {
                    SoftParticlesHintGUI();
                }
            }

            EditorGUILayout.PropertyField(realtimeReflectionProbes);
            EditorGUILayout.PropertyField(billboardsFaceCameraPosition, Content.kBillboardsFaceCameraPos);
            EditorGUILayout.PropertyField(resolutionScalingFixedDPIFactorProperty);

            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("Shadows"), EditorStyles.boldLabel);
            if (SupportedRenderingFeatures.IsMixedLightingModeSupported(MixedLightingMode.Shadowmask))
            {
                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("Other"), EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(blendWeightsProperty);
            EditorGUILayout.PropertyField(vSyncCountProperty);
            EditorGUILayout.PropertyField(lodBiasProperty);
            EditorGUILayout.PropertyField(maximumLODLevelProperty);
            EditorGUILayout.PropertyField(particleRaycastBudgetProperty);
            EditorGUILayout.PropertyField(asyncUploadTimeSliceProperty);
            EditorGUILayout.PropertyField(asyncUploadBufferSizeProperty);

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

            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();
        }
        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();
        }
Example #11
0
 private void MoveDown(SerializedProperty property, int i) {
     property.MoveArrayElement(i, i + 1);
 }
Example #12
0
 private void MoveUp(SerializedProperty property, int i) {
     property.MoveArrayElement(i, i - 1);
 }