private static GUIContent CreateLabelWithTooltip(VRTK_AdaptiveQuality adaptiveQuality, string fieldName) { var fieldInfo = adaptiveQuality.GetType().GetField(fieldName); var tooltipAttribute = (TooltipAttribute)Attribute.GetCustomAttribute(fieldInfo, typeof(TooltipAttribute)); return(new GUIContent(ObjectNames.NicifyVariableName(fieldName), tooltipAttribute.tooltip)); }
private static void AddHeader(VRTK_AdaptiveQuality adaptiveQuality, string fieldName) { var fieldInfo = adaptiveQuality.GetType().GetField(fieldName); var headerAttribute = (HeaderAttribute)Attribute.GetCustomAttribute(fieldInfo, typeof(HeaderAttribute)); EditorGUILayout.Space(); EditorGUILayout.LabelField(headerAttribute.header, EditorStyles.boldLabel); }
// Token: 0x06001B84 RID: 7044 RVA: 0x0008FCD8 File Offset: 0x0008DED8 public override string ToString() { StringBuilder stringBuilder = new StringBuilder("Adaptive Quality\n"); stringBuilder.AppendLine("Render Scale:"); stringBuilder.AppendLine("Level - Resolution - Multiplier"); for (int i = 0; i < this.allRenderScales.Count; i++) { float num = this.allRenderScales[i]; Vector2 vector = VRTK_AdaptiveQuality.RenderTargetResolutionForRenderScale(num); stringBuilder.AppendFormat("{0, 3} {1, 5}x{2, -5} {3, -8}", new object[] { i, (int)vector.x, (int)vector.y, num }); if (i == 0) { stringBuilder.Append(" (Interleaved reprojection hint)"); } else if (i == this.defaultRenderViewportScaleLevel) { stringBuilder.Append(" (Default)"); } if (i == this.renderViewportScaleSetting.currentValue) { stringBuilder.Append(" (Current Viewport)"); } if (i == this.renderScaleSetting.currentValue) { stringBuilder.Append(" (Current Target Resolution)"); } if (i != this.allRenderScales.Count - 1) { stringBuilder.AppendLine(); } } return(stringBuilder.ToString()); }
// Token: 0x06001B91 RID: 7057 RVA: 0x00090340 File Offset: 0x0008E540 private void UpdateRenderScale() { if (this.allRenderScales.Count == 0) { return; } if (!this.scaleRenderViewport) { this.renderViewportScaleSetting.currentValue = this.defaultRenderViewportScaleLevel; this.renderScaleSetting.currentValue = this.defaultRenderViewportScaleLevel; VRTK_AdaptiveQuality.SetRenderScale(1f, 1f); return; } float num = VRTK_SDK_Bridge.ShouldAppRenderWithLowResources() ? (this.singleFrameDurationInMilliseconds * 0.75f) : this.singleFrameDurationInMilliseconds; float thresholdInMilliseconds = 0.7f * num; float extrapolationThresholdInMilliseconds = 0.85f * num; float thresholdInMilliseconds2 = 0.9f * num; int num2 = this.renderViewportScaleSetting.currentValue; if (this.timing.WasFrameTimingBad(1, thresholdInMilliseconds2, this.renderViewportScaleSetting.lastChangeFrameCount, this.renderViewportScaleSetting.decreaseFrameCost) || this.timing.WasFrameTimingBad(3, thresholdInMilliseconds2, this.renderViewportScaleSetting.lastChangeFrameCount, this.renderViewportScaleSetting.decreaseFrameCost) || this.timing.WillFrameTimingBeBad(extrapolationThresholdInMilliseconds, thresholdInMilliseconds2, this.renderViewportScaleSetting.lastChangeFrameCount, this.renderViewportScaleSetting.decreaseFrameCost)) { num2 = this.ClampRenderScaleLevel((this.renderViewportScaleSetting.currentValue == 2) ? 1 : (this.renderViewportScaleSetting.currentValue - 2)); } else if (this.timing.WasFrameTimingGood(12, thresholdInMilliseconds, this.renderViewportScaleSetting.lastChangeFrameCount - this.renderViewportScaleSetting.increaseFrameCost, this.renderViewportScaleSetting.increaseFrameCost)) { num2 = this.ClampRenderScaleLevel(this.renderViewportScaleSetting.currentValue + 2); } else if (this.timing.WasFrameTimingGood(6, thresholdInMilliseconds, this.renderViewportScaleSetting.lastChangeFrameCount, this.renderViewportScaleSetting.increaseFrameCost)) { num2 = this.ClampRenderScaleLevel(this.renderViewportScaleSetting.currentValue + 1); } if (num2 != this.renderViewportScaleSetting.currentValue) { if (this.renderViewportScaleSetting.currentValue >= this.renderScaleSetting.currentValue && num2 < this.renderScaleSetting.currentValue) { this.lastRenderViewportScaleLevelBelowRenderScaleLevelFrameCount = Time.frameCount; } this.renderViewportScaleSetting.currentValue = num2; } if (this.overrideRenderViewportScale) { this.renderViewportScaleSetting.currentValue = this.overrideRenderViewportScaleLevel; } float num3 = 1f; if (!this.hmdDisplayIsOnDesktop) { if (this.renderViewportScaleSetting.currentValue == 0) { if (this.interleavedReprojectionEnabled && this.timing.GetFrameTiming(0) < this.singleFrameDurationInMilliseconds * 0.85f) { this.interleavedReprojectionEnabled = false; } else if (this.timing.GetFrameTiming(0) > this.singleFrameDurationInMilliseconds * 0.925f) { this.interleavedReprojectionEnabled = true; } } else { this.interleavedReprojectionEnabled = false; } VRTK_SDK_Bridge.ForceInterleavedReprojectionOn(this.interleavedReprojectionEnabled); } else if (this.renderViewportScaleSetting.currentValue == 0) { num3 = 0.8f; } int currentValue = this.renderScaleSetting.currentValue; int b = (this.renderViewportScaleSetting.currentValue - this.renderScaleSetting.currentValue) / 2; if (this.renderScaleSetting.currentValue < this.renderViewportScaleSetting.currentValue && Time.frameCount >= this.renderScaleSetting.lastChangeFrameCount + this.renderScaleSetting.increaseFrameCost) { currentValue = this.ClampRenderScaleLevel(this.renderScaleSetting.currentValue + Mathf.Max(1, b)); } else if (this.renderScaleSetting.currentValue > this.renderViewportScaleSetting.currentValue && Time.frameCount >= this.renderScaleSetting.lastChangeFrameCount + this.renderScaleSetting.decreaseFrameCost && Time.frameCount >= this.lastRenderViewportScaleLevelBelowRenderScaleLevelFrameCount + this.renderViewportScaleSetting.increaseFrameCost) { currentValue = (this.timing.WasFrameTimingGood(6, thresholdInMilliseconds, 0, 0) ? this.ClampRenderScaleLevel(this.renderScaleSetting.currentValue + Mathf.Min(-1, b)) : this.renderViewportScaleSetting.currentValue); } this.renderScaleSetting.currentValue = currentValue; if (!this.scaleRenderTargetResolution) { this.renderScaleSetting.currentValue = this.allRenderScales.Count - 1; } float num4 = this.allRenderScales[this.renderScaleSetting.currentValue]; float renderViewportScale = this.allRenderScales[Mathf.Min(this.renderViewportScaleSetting.currentValue, this.renderScaleSetting.currentValue)] / num4 * num3; VRTK_AdaptiveQuality.SetRenderScale(num4, renderViewportScale); }
// Token: 0x06001B87 RID: 7047 RVA: 0x0008FE63 File Offset: 0x0008E063 private void OnDisable() { Camera.onPreCull = (Camera.CameraCallback)Delegate.Remove(Camera.onPreCull, new Camera.CameraCallback(this.OnCameraPreCull)); VRTK_AdaptiveQuality.SetRenderScale(1f, 1f); }
public override void OnInspectorGUI() { serializedObject.Update(); VRTK_AdaptiveQuality adaptiveQuality = (VRTK_AdaptiveQuality)target; EditorGUILayout.HelpBox(DontDisableHelpBoxText, adaptiveQuality.enabled ? MessageType.Warning : MessageType.Error); EditorGUILayout.Space(); EditorGUILayout.PropertyField(serializedObject.FindProperty("drawDebugVisualization")); EditorGUILayout.PropertyField(serializedObject.FindProperty("allowKeyboardShortcuts")); EditorGUILayout.PropertyField(serializedObject.FindProperty("allowCommandLineArguments")); EditorGUILayout.PropertyField(serializedObject.FindProperty("msaaLevel")); EditorGUILayout.Space(); serializedObject.FindProperty("scaleRenderViewport").boolValue = EditorGUILayout.BeginToggleGroup(VRTK_EditorUtilities.BuildGUIContent <VRTK_AdaptiveQuality>("scaleRenderViewport"), adaptiveQuality.scaleRenderViewport); { Limits2D renderScaleLimits = adaptiveQuality.renderScaleLimits; EditorGUILayout.PropertyField(serializedObject.FindProperty("renderScaleLimits")); if (renderScaleLimits.maximum > adaptiveQuality.BiggestAllowedMaximumRenderScale()) { EditorGUILayout.HelpBox(MaximumRenderScaleTooBigHelpBoxText, MessageType.Error); } EditorGUILayout.PropertyField(serializedObject.FindProperty("maximumRenderTargetDimension")); EditorGUILayout.PropertyField(serializedObject.FindProperty("renderScaleFillRateStepSizeInPercent")); serializedObject.FindProperty("scaleRenderTargetResolution").boolValue = EditorGUILayout.Toggle(VRTK_EditorUtilities.BuildGUIContent <VRTK_AdaptiveQuality>("scaleRenderTargetResolution"), adaptiveQuality.scaleRenderTargetResolution); if (adaptiveQuality.scaleRenderTargetResolution) { EditorGUILayout.HelpBox(ScaleRenderTargetResolutionCostlyHelpBoxText, MessageType.Warning); } int maxRenderScaleLevel = Mathf.Max(adaptiveQuality.renderScales.Count - 1, 0); bool disabled = maxRenderScaleLevel == 0 || !Application.isPlaying; EditorGUI.BeginDisabledGroup(disabled); { VRTK_EditorUtilities.AddHeader <VRTK_AdaptiveQuality>("overrideRenderViewportScale"); if (disabled) { EditorGUI.EndDisabledGroup(); { EditorGUILayout.HelpBox(NoRenderScaleLevelsYetHelpBoxText, MessageType.Info); } EditorGUI.BeginDisabledGroup(true); } adaptiveQuality.overrideRenderViewportScale = EditorGUILayout.Toggle( VRTK_EditorUtilities.BuildGUIContent <VRTK_AdaptiveQuality>("overrideRenderViewportScale"), adaptiveQuality.overrideRenderViewportScale); EditorGUI.BeginDisabledGroup(!adaptiveQuality.overrideRenderViewportScale); { adaptiveQuality.overrideRenderViewportScaleLevel = EditorGUILayout.IntSlider( VRTK_EditorUtilities.BuildGUIContent <VRTK_AdaptiveQuality>("overrideRenderViewportScaleLevel"), adaptiveQuality.overrideRenderViewportScaleLevel, 0, maxRenderScaleLevel); } EditorGUI.EndDisabledGroup(); } EditorGUI.EndDisabledGroup(); } EditorGUILayout.EndToggleGroup(); if (Application.isPlaying) { string summary = adaptiveQuality.ToString(); summary = summary.Substring(summary.IndexOf("\n", StringComparison.Ordinal) + 1); VRTK_EditorUtilities.AddHeader("Current State"); EditorGUILayout.HelpBox(summary, MessageType.None); if (GUILayout.RepeatButton("Refresh")) { Repaint(); } } serializedObject.ApplyModifiedProperties(); }