发包版本
This commit is contained in:
56
Assets/Scripts/UI/Base/UiExpandingContoursEffect.cs
Normal file
56
Assets/Scripts/UI/Base/UiExpandingContoursEffect.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Ichni.UI
|
||||
{
|
||||
/// <summary>
|
||||
/// 将装饰性 UI Image 纳入「UI 效果」图形设置。
|
||||
/// <para>
|
||||
/// 此组件应只挂在使用 <c>UI_ExpandingContours</c> 等可选视觉 Shader 的 Image 上。
|
||||
/// 关闭设置时仅禁用目标 Image 的绘制,不会停用 GameObject,因此布局与子物体状态不受影响。
|
||||
/// 目标应为不承载输入的装饰性 Image。
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// 新增同类 UI 特效时,只需在对应 Image 上添加本组件;无需再在 SettingsManager 中硬编码页面或物体名称。
|
||||
/// </para>
|
||||
/// </summary>
|
||||
[DisallowMultipleComponent]
|
||||
[RequireComponent(typeof(Graphic))]
|
||||
public sealed class UiExpandingContoursEffect : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Graphic targetGraphic;
|
||||
|
||||
private void Reset()
|
||||
{
|
||||
targetGraphic = GetComponent<Graphic>();
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (targetGraphic == null)
|
||||
{
|
||||
targetGraphic = GetComponent<Graphic>();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
// 页面首次显示或从隐藏状态恢复时,重新读取已经加载的玩家设置。
|
||||
bool enableUiEffects = SettingsManager.instance?.settingsSaveData?.enableUiEffects ?? true;
|
||||
ApplyEnabledState(enableUiEffects);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置目标 Image 是否参与绘制。由 SettingsManager 在载入存档、场景切换和玩家切换开关时调用。
|
||||
/// </summary>
|
||||
public void ApplyEnabledState(bool enableUiEffects)
|
||||
{
|
||||
if (targetGraphic == null)
|
||||
{
|
||||
targetGraphic = GetComponent<Graphic>();
|
||||
}
|
||||
|
||||
targetGraphic.enabled = enableUiEffects;
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/UI/Base/UiExpandingContoursEffect.cs.meta
Normal file
2
Assets/Scripts/UI/Base/UiExpandingContoursEffect.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e47bc8701d1c446184bf62bffaf104f2
|
||||
@@ -48,6 +48,7 @@ namespace Ichni.Menu
|
||||
public Switch postProcessingSwitch;
|
||||
public Dropdown bloomQualityDropdown;
|
||||
public Dropdown vfxQualityDropdown;
|
||||
public Switch uiEffectsSwitch;
|
||||
public Switch vSyncSwitch;
|
||||
public Dropdown displayModeDropdown;
|
||||
public Dropdown displayResolutionDropdown;
|
||||
@@ -78,6 +79,7 @@ namespace Ichni.Menu
|
||||
};
|
||||
|
||||
InitializePostProcessingSettings();
|
||||
InitializeUiEffectsSettings();
|
||||
|
||||
#if UNITY_STANDALONE || UNITY_EDITOR
|
||||
InitializeDesktopDisplaySettings();
|
||||
@@ -101,6 +103,11 @@ namespace Ichni.Menu
|
||||
vfxQualityDropdown.SetValue((int)gameSettings.vfxQuality);
|
||||
}
|
||||
|
||||
if (uiEffectsSwitch != null)
|
||||
{
|
||||
uiEffectsSwitch.SetValue(gameSettings.enableUiEffects);
|
||||
}
|
||||
|
||||
#if UNITY_STANDALONE || UNITY_EDITOR
|
||||
vSyncSwitch.SetValue(gameSettings.vSyncEnabled);
|
||||
displayModeDropdown.SetValue((int)gameSettings.displayMode);
|
||||
@@ -141,6 +148,27 @@ namespace Ichni.Menu
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 初始化 UI 特效开关。
|
||||
/// 它独立于后处理和 VFX 质量:关闭后只停止标记为 UiExpandingContoursEffect 的 UI Image 绘制,
|
||||
/// 不会影响游戏内 Note 特效、相机后处理或普通 UI。
|
||||
/// </summary>
|
||||
private void InitializeUiEffectsSettings()
|
||||
{
|
||||
// 兼容尚未补齐新控件的旧 Settings Prefab;完成界面布置后必须在 Inspector 绑定该引用。
|
||||
if (uiEffectsSwitch == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
uiEffectsSwitch.SetUp(gameSettings.enableUiEffects);
|
||||
uiEffectsSwitch.updateValueAction = () =>
|
||||
{
|
||||
gameSettings.enableUiEffects = uiEffectsSwitch.GetValue();
|
||||
SettingsManager.instance.ApplyUiEffectsSettings();
|
||||
};
|
||||
}
|
||||
|
||||
#if UNITY_STANDALONE || UNITY_EDITOR
|
||||
private void InitializeDesktopDisplaySettings()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user