void DrawElementCallback(Rect rect, int index, bool isactive, bool isfocused) { SerializedProperty element = m_ReorderableList.serializedProperty.GetArrayElementAtIndex(index); rect.y += 2; var name = element.FindPropertyRelative(k_ScalerName).stringValue; ScalerProfileSettingInformation scalerProfileSettingInfo; if (!m_ScalerProfiles.TryGetValue(name, out scalerProfileSettingInfo)) { scalerProfileSettingInfo = new ScalerProfileSettingInformation() { showScalerProfileSettings = false }; } rect.width -= 6; rect.height = EditorGUIUtility.singleLineHeight; scalerProfileSettingInfo.showScalerProfileSettings = EditorGUI.Foldout(rect, scalerProfileSettingInfo.showScalerProfileSettings, new GUIContent($"{name}"), true); if (scalerProfileSettingInfo.showScalerProfileSettings) { AdaptivePerformanceScalerSettings settingsObject = new AdaptivePerformanceScalerSettings(); Type settingsType = settingsObject.GetType(); MemberInfo[] memberInfo = settingsType.GetProperties(); rect.x += 10; rect.width -= 10; for (int i = 0; i < memberInfo.Length; i++) { if (memberInfo[i].Name == "AdaptiveShadowCascades") // ap-obsolete-001 due to renaming the property { continue; } var scalerSetting = element.FindPropertyRelative($"m_{memberInfo[i].Name}"); rect = DrawScalerSetting(rect, scalerSetting, m_IndexerActiveProperty.boolValue && !EditorApplication.isPlayingOrWillChangePlaymode, scalerProfileSettingInfo); } } m_ScalerProfiles[name] = scalerProfileSettingInfo; }
Rect DrawScalerSetting(Rect rect, SerializedProperty scalerSetting, bool renderNotDisabled, ScalerProfileSettingInformation scalerProfileSettingInfo) { string name = scalerSetting.FindPropertyRelative(k_ScalerName).stringValue; var isEnabled = renderNotDisabled && !EditorApplication.isPlayingOrWillChangePlaymode; var isFrameRateScaler = name == s_AdaptiveFramerateMenu; if (isFrameRateScaler && QualitySettings.vSyncCount > 0) { isEnabled = false; } GUI.enabled = isEnabled; rect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; ScalerSettingInformation scalerSettingInfo; if (!scalerProfileSettingInfo.scalerSettingsInfos.TryGetValue(name, out scalerSettingInfo)) { scalerSettingInfo = new ScalerSettingInformation() { showScalerSettings = false }; } rect.x += k_TickboxPosition; var needsFoldout = scalerSetting.FindPropertyRelative(k_ScalerEnabled).boolValue; EditorGUI.BeginChangeCheck(); bool newValue = EditorGUI.Toggle(rect, GUIContent.none, needsFoldout); if (EditorGUI.EndChangeCheck()) { needsFoldout = newValue; if (newValue) { scalerSettingInfo.showScalerSettings = newValue; } } scalerSetting.FindPropertyRelative(k_ScalerEnabled).boolValue = needsFoldout; rect.x -= k_TickboxPosition; if (needsFoldout || !isEnabled) { EditorGUI.BeginChangeCheck(); var newShowScalerSettings = EditorGUI.Foldout(rect, scalerSettingInfo.showScalerSettings, ReturnScalerGUIContent(name), true); if (EditorGUI.EndChangeCheck()) { scalerSettingInfo.showScalerSettings = newShowScalerSettings; } } else { EditorGUI.LabelField(rect, ReturnScalerGUIContent(name)); } if ((needsFoldout || !isEnabled) && scalerSettingInfo.showScalerSettings) { rect.x += 10; rect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; if (isFrameRateScaler && QualitySettings.vSyncCount > 0) { GUI.enabled = true; rect.x += 10; rect.width -= 10; rect.height += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; EditorGUI.HelpBox(rect, s_FrameRateWarning, MessageType.Warning); rect.height -= EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; rect.x -= 10; rect.width += 10; rect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing + EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; GUI.enabled = isEnabled; } var minBound = scalerSetting.FindPropertyRelative(k_ScalerMinBound).floatValue; var maxBound = scalerSetting.FindPropertyRelative(k_ScalerMaxBound).floatValue; EditorGUI.BeginChangeCheck(); float newMinBound = EditorGUI.FloatField(rect, s_ScalerMinBound, minBound); if (EditorGUI.EndChangeCheck()) { minBound = Mathf.Clamp(newMinBound, 0, maxBound); } scalerSetting.FindPropertyRelative(k_ScalerMinBound).floatValue = minBound; rect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; EditorGUI.BeginChangeCheck(); float newMaxBound = EditorGUI.FloatField(rect, s_ScalerMaxBound, maxBound); if (EditorGUI.EndChangeCheck()) { maxBound = Mathf.Clamp(newMaxBound, minBound, 10000); } scalerSetting.FindPropertyRelative(k_ScalerMaxBound).floatValue = maxBound; rect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; var maxLevel = scalerSetting.FindPropertyRelative(k_ScalerMaxLevel).intValue; EditorGUI.BeginChangeCheck(); int newMaxLevel = EditorGUI.IntField(rect, s_ScalerMaxLevel, maxLevel); if (EditorGUI.EndChangeCheck()) { maxLevel = Mathf.Clamp(newMaxLevel, 1, 100); } scalerSetting.FindPropertyRelative(k_ScalerMaxLevel).intValue = maxLevel; rect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; ScalerVisualImpact visualImpact = (ScalerVisualImpact)scalerSetting.FindPropertyRelative(k_ScalerVisualImpact).enumValueIndex; EditorGUI.BeginChangeCheck(); ScalerVisualImpact newVisualImpact = (ScalerVisualImpact)EditorGUI.EnumPopup(rect, s_ScalerVisualImpact, visualImpact); if (EditorGUI.EndChangeCheck()) { visualImpact = (ScalerVisualImpact)Mathf.Clamp((int)newVisualImpact, (int)ScalerVisualImpact.Low, (int)ScalerVisualImpact.High); } scalerSetting.FindPropertyRelative(k_ScalerVisualImpact).enumValueIndex = (int)visualImpact; rect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; ScalerTarget staticFlagMask = (ScalerTarget)scalerSetting.FindPropertyRelative(k_ScalerTarget).intValue; GUIContent propDisplayNames = new GUIContent(""); foreach (var enumValue in Enum.GetValues(typeof(ScalerTarget))) { int checkBit = (int)staticFlagMask & (int)enumValue; if (checkBit != 0) { propDisplayNames.text += propDisplayNames.text.Length != 0 ? " | " : ""; propDisplayNames.text += enumValue.ToString(); } } EditorGUI.LabelField(rect, s_ScalerTarget, propDisplayNames); rect.x -= 10; } scalerProfileSettingInfo.scalerSettingsInfos[name] = scalerSettingInfo; return(rect); }