unityzgy/.svn/pristine/ef/ef077a6a1a3aeed38224a2e632beee0b77ade1f6.svn-base
ayuan9957 bf12e02276 feat: 多语言本地化系统 - 支持中/英/法/俄实时切换
- LocalizationManager: 新增翻译表(SetFormatted/SetDuration/LocalizeOperateMsg)
- LoginPanel: InputField placeholder本地化、字体颜色保持
- HistoryPanel: 用时数据本地化、placeholder本地化
- RecordDetailPanel: 操作详情消息本地化(LanguageChanged重建)
- AppraiseWindowBase: 评价等级本地化、操作消息重建
- EditorAppraiser: 所有评估消息改用InjectOperateMsgLocalized
- StudentOperateRecorder: 新增InjectOperateMsgLocalized方法
- LocalizationLanguageTestBar: 单例模式、ScreenSpaceOverlay筛选
- 字体切换时保留颜色和verticalOverflow
2026-07-16 10:05:59 +08:00

147 lines
7.5 KiB
Plaintext

#if (UNITY_5_4_OR_NEWER)
namespace VRTK
{
using System;
using System.Globalization;
using UnityEditor;
using UnityEngine;
[CustomEditor(typeof(VRTK_AdaptiveQuality))]
public class VRTK_AdaptiveQualityEditor : Editor
{
private const string DontDisableHelpBoxText =
"This script supports command line arguments to configure the adaptive quality scaling."
+ " If this script is disabled it won't respond to the arguments.\n\n"
+ "Leave this script enabled and use the `scaleRenderViewport` property if you want to disable"
+ " the adaptive quality scaling for now, but want to leave it possible for your built"
+ " binary to respond to the arguments.";
private const string MaximumRenderScaleTooBigHelpBoxText =
"The maximum render scale is too big. It's constrained by the maximum render target dimension below.";
private const string ScaleRenderTargetResolutionCostlyHelpBoxText =
"Changing the render target resolution is very costly and should be reduced to a minimum, therefore"
+ " this setting is turned off by default. Make sure you understand the performance implication this"
+ " setting has when leaving it enabled.";
private const string NoRenderScaleLevelsYetHelpBoxText =
"Overriding render viewport scale levels is disabled because there are no render viewport scale levels calculated yet."
+ " They will be calculated at runtime.";
public override void OnInspectorGUI()
{
serializedObject.Update();
var 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);
{
float minimumRenderScale = adaptiveQuality.minimumRenderScale;
float maximumRenderScale = adaptiveQuality.maximumRenderScale;
EditorGUILayout.BeginHorizontal();
{
var fieldInfo = adaptiveQuality.GetType().GetField("minimumRenderScale");
var rangeAttribute = (RangeAttribute)Attribute.GetCustomAttribute(fieldInfo, typeof(RangeAttribute));
EditorGUI.BeginChangeCheck();
{
float maxFloatWidth = GUI.skin.textField.CalcSize(new GUIContent(1.23f.ToString(CultureInfo.InvariantCulture))).x;
minimumRenderScale = EditorGUILayout.FloatField(minimumRenderScale, GUILayout.MaxWidth(maxFloatWidth));
EditorGUILayout.MinMaxSlider(
ref minimumRenderScale,
ref maximumRenderScale,
rangeAttribute.min,
rangeAttribute.max);
maximumRenderScale = EditorGUILayout.FloatField(maximumRenderScale, GUILayout.MaxWidth(maxFloatWidth));
}
if (EditorGUI.EndChangeCheck())
{
serializedObject.FindProperty("minimumRenderScale").floatValue =
Mathf.Clamp((float)Math.Round(minimumRenderScale, 2), rangeAttribute.min, rangeAttribute.max);
serializedObject.FindProperty("maximumRenderScale").floatValue =
Mathf.Clamp((float)Math.Round(maximumRenderScale, 2), rangeAttribute.min, rangeAttribute.max);
}
}
EditorGUILayout.EndHorizontal();
if (maximumRenderScale > 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();
}
}
}
#endif