1. 调整 UI 以适配新的分辨率 2. 导入素材并将素材应用到 UI 上
This commit is contained in:
@@ -15,7 +15,7 @@ namespace CustomComponent
|
||||
public class DialogComponent : GameFrameworkComponent
|
||||
{
|
||||
#region Property
|
||||
|
||||
|
||||
private const int DialogChapterDivisor = 1000;
|
||||
private const int LineChapterDivisor = 100000000;
|
||||
private const int LineDialogDivisor = 100000;
|
||||
@@ -35,7 +35,7 @@ namespace CustomComponent
|
||||
private int _currentLineIndex = -1;
|
||||
private bool _isInitialized;
|
||||
private bool _isPlaying;
|
||||
|
||||
|
||||
public bool IsInitialized => _isInitialized;
|
||||
|
||||
public bool IsPlaying => _isPlaying;
|
||||
@@ -105,9 +105,8 @@ namespace CustomComponent
|
||||
}
|
||||
|
||||
DRDialogLine[] lineRows = _dtDialogLine.GetDataRows((a, b) => a.Id.CompareTo(b.Id));
|
||||
for (int i = 0; i < lineRows.Length; i++)
|
||||
foreach (var lineRow in lineRows)
|
||||
{
|
||||
DRDialogLine lineRow = lineRows[i];
|
||||
if (lineRow == null)
|
||||
{
|
||||
continue;
|
||||
@@ -134,7 +133,7 @@ namespace CustomComponent
|
||||
}
|
||||
|
||||
List<int> invalidDialogIds = new List<int>();
|
||||
foreach (KeyValuePair<int, DRDialog> dialogPair in _dialogMap)
|
||||
foreach (var dialogPair in _dialogMap)
|
||||
{
|
||||
if (!_dialogLinesMap.TryGetValue(dialogPair.Key, out List<DRDialogLine> dialogLines) ||
|
||||
dialogLines.Count == 0)
|
||||
@@ -149,9 +148,9 @@ namespace CustomComponent
|
||||
_dialogFirstLineIdMap[dialogPair.Key] = dialogLines[0].Id;
|
||||
}
|
||||
|
||||
for (int i = 0; i < invalidDialogIds.Count; i++)
|
||||
foreach (var id in invalidDialogIds)
|
||||
{
|
||||
_dialogMap.Remove(invalidDialogIds[i]);
|
||||
_dialogMap.Remove(id);
|
||||
}
|
||||
|
||||
if (_dialogMap.Count == 0)
|
||||
@@ -212,8 +211,10 @@ namespace CustomComponent
|
||||
_formContext.DialogId = dialogRow.Id;
|
||||
_formContext.DialogTitle = dialogRow.Title;
|
||||
_formContext.DialogUIMode = dialogRow.UIMode;
|
||||
_formContext.PlayingSpeed = (DialogPlayingSpeed)GameEntry.Setting.GetInt(Constant.Setting.DialogPlayingSpeed);
|
||||
_formContext.DialogWindowAlpha = (DialogWindowAlpha)GameEntry.Setting.GetInt(Constant.Setting.DialogWindowAlpha);
|
||||
_formContext.PlayingSpeed =
|
||||
(DialogPlayingSpeed)GameEntry.Setting.GetInt(Constant.Setting.DialogPlayingSpeed);
|
||||
_formContext.DialogWindowAlpha =
|
||||
(DialogWindowAlpha)GameEntry.Setting.GetInt(Constant.Setting.DialogWindowAlpha);
|
||||
|
||||
_currentLineIndex = 0;
|
||||
ApplyLineToContext(dialogLines[_currentLineIndex], _currentLineIndex, dialogLines.Count);
|
||||
@@ -407,4 +408,4 @@ namespace CustomComponent
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,445 @@
|
||||
using System.Collections.Generic;
|
||||
using GameFramework.Event;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace GeometryTD.CustomComponent
|
||||
{
|
||||
/// <summary>
|
||||
/// Keeps gameplay camera and UI in a fixed design aspect, then fills extra area with black masks.
|
||||
/// </summary>
|
||||
public class ResolutionAdapterComponent : GameFrameworkComponent
|
||||
{
|
||||
private const float DefaultCanvasPlaneDistance = 100f;
|
||||
|
||||
[SerializeField] private Vector2 _referenceResolution = new Vector2(2560f, 1600f);
|
||||
[SerializeField] private bool _adaptUiCanvasToViewport = true;
|
||||
[SerializeField] private bool _enableBlackMask = true;
|
||||
[SerializeField] private List<Transform> _uiRoots = new List<Transform>();
|
||||
|
||||
private readonly List<Canvas> _canvasBuffer = new List<Canvas>(32);
|
||||
private readonly List<Canvas> _trackedCanvases = new List<Canvas>(32);
|
||||
private readonly HashSet<Canvas> _trackedCanvasSet = new HashSet<Canvas>();
|
||||
|
||||
private Camera _mainCamera;
|
||||
private Rect _targetViewport = new Rect(0f, 0f, 1f, 1f);
|
||||
private int _cachedScreenWidth = -1;
|
||||
private int _cachedScreenHeight = -1;
|
||||
|
||||
private bool _canvasCacheDirty = true;
|
||||
private bool _uiEventSubscribed;
|
||||
private bool _missingRootWarned;
|
||||
|
||||
private Canvas _maskCanvas;
|
||||
private RectTransform _leftMask;
|
||||
private RectTransform _rightMask;
|
||||
private RectTransform _topMask;
|
||||
private RectTransform _bottomMask;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
TryEnsureUiEventSubscribed();
|
||||
ApplyAdaptation(true);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
TryEnsureUiEventSubscribed();
|
||||
ApplyAdaptation(false);
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
UnsubscribeUiEvents();
|
||||
|
||||
if (_mainCamera != null)
|
||||
{
|
||||
_mainCamera.rect = new Rect(0f, 0f, 1f, 1f);
|
||||
}
|
||||
}
|
||||
|
||||
private void ApplyAdaptation(bool force)
|
||||
{
|
||||
if (_referenceResolution.x <= 0f || _referenceResolution.y <= 0f)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Camera resolvedCamera = ResolveMainCamera();
|
||||
bool cameraChanged = resolvedCamera != _mainCamera;
|
||||
bool screenChanged = Screen.width != _cachedScreenWidth || Screen.height != _cachedScreenHeight;
|
||||
bool needRecalculate = force || cameraChanged || screenChanged;
|
||||
|
||||
if (needRecalculate)
|
||||
{
|
||||
Camera lastCamera = _mainCamera;
|
||||
if (lastCamera != null && lastCamera != resolvedCamera)
|
||||
{
|
||||
lastCamera.rect = new Rect(0f, 0f, 1f, 1f);
|
||||
}
|
||||
|
||||
_mainCamera = resolvedCamera;
|
||||
_cachedScreenWidth = Screen.width;
|
||||
_cachedScreenHeight = Screen.height;
|
||||
_targetViewport = CalculateViewport(_cachedScreenWidth, _cachedScreenHeight);
|
||||
|
||||
ApplyCameraViewport();
|
||||
UpdateMaskLayout();
|
||||
}
|
||||
|
||||
if (!_adaptUiCanvasToViewport)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!needRecalculate && !_canvasCacheDirty)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ApplyCanvasAdaptation();
|
||||
}
|
||||
|
||||
private Camera ResolveMainCamera()
|
||||
{
|
||||
if (GameEntry.Scene != null && GameEntry.Scene.MainCamera != null)
|
||||
{
|
||||
return GameEntry.Scene.MainCamera;
|
||||
}
|
||||
|
||||
if (Camera.main != null)
|
||||
{
|
||||
return Camera.main;
|
||||
}
|
||||
|
||||
if (_mainCamera != null && _mainCamera.isActiveAndEnabled)
|
||||
{
|
||||
return _mainCamera;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private Rect CalculateViewport(int width, int height)
|
||||
{
|
||||
if (width <= 0 || height <= 0)
|
||||
{
|
||||
return new Rect(0f, 0f, 1f, 1f);
|
||||
}
|
||||
|
||||
float referenceAspect = _referenceResolution.x / _referenceResolution.y;
|
||||
float screenAspect = (float)width / height;
|
||||
|
||||
if (Mathf.Approximately(referenceAspect, screenAspect))
|
||||
{
|
||||
return new Rect(0f, 0f, 1f, 1f);
|
||||
}
|
||||
|
||||
if (screenAspect > referenceAspect)
|
||||
{
|
||||
float viewportWidth = referenceAspect / screenAspect;
|
||||
return new Rect((1f - viewportWidth) * 0.5f, 0f, viewportWidth, 1f);
|
||||
}
|
||||
|
||||
float viewportHeight = screenAspect / referenceAspect;
|
||||
return new Rect(0f, (1f - viewportHeight) * 0.5f, 1f, viewportHeight);
|
||||
}
|
||||
|
||||
private void ApplyCameraViewport()
|
||||
{
|
||||
if (_mainCamera == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_mainCamera.rect = _targetViewport;
|
||||
}
|
||||
|
||||
private void ApplyCanvasAdaptation()
|
||||
{
|
||||
if (_mainCamera == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_uiRoots == null || _uiRoots.Count == 0)
|
||||
{
|
||||
if (!_missingRootWarned)
|
||||
{
|
||||
_missingRootWarned = true;
|
||||
Log.Warning(
|
||||
"ResolutionAdapterComponent missing injected roots. Assign UI/HPBar root transforms in scene.");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (_canvasCacheDirty)
|
||||
{
|
||||
RebuildCanvasCache();
|
||||
}
|
||||
|
||||
for (int i = _trackedCanvases.Count - 1; i >= 0; i--)
|
||||
{
|
||||
Canvas canvas = _trackedCanvases[i];
|
||||
if (canvas == null)
|
||||
{
|
||||
_trackedCanvases.RemoveAt(i);
|
||||
_canvasCacheDirty = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
ApplyCanvasSettings(canvas);
|
||||
}
|
||||
}
|
||||
|
||||
private void RebuildCanvasCache()
|
||||
{
|
||||
_canvasCacheDirty = false;
|
||||
_trackedCanvases.Clear();
|
||||
_trackedCanvasSet.Clear();
|
||||
|
||||
foreach (var root in _uiRoots)
|
||||
{
|
||||
CollectCanvases(root);
|
||||
}
|
||||
}
|
||||
|
||||
private void CollectCanvases(Transform root)
|
||||
{
|
||||
if (root == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
root.GetComponentsInChildren(true, _canvasBuffer);
|
||||
foreach (Canvas canvas in _canvasBuffer)
|
||||
{
|
||||
if (canvas == null || canvas == _maskCanvas || canvas.renderMode == RenderMode.WorldSpace)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (_trackedCanvasSet.Add(canvas))
|
||||
{
|
||||
_trackedCanvases.Add(canvas);
|
||||
}
|
||||
}
|
||||
|
||||
_canvasBuffer.Clear();
|
||||
}
|
||||
|
||||
private void ApplyCanvasSettings(Canvas canvas)
|
||||
{
|
||||
if (canvas == _maskCanvas || canvas.renderMode == RenderMode.WorldSpace)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
canvas.renderMode = RenderMode.ScreenSpaceCamera;
|
||||
canvas.worldCamera = _mainCamera;
|
||||
canvas.planeDistance = ResolveCanvasPlaneDistance(_mainCamera);
|
||||
|
||||
CanvasScaler scaler = canvas.GetComponent<CanvasScaler>();
|
||||
if (scaler != null)
|
||||
{
|
||||
scaler.uiScaleMode = CanvasScaler.ScaleMode.ScaleWithScreenSize;
|
||||
scaler.referenceResolution = _referenceResolution;
|
||||
scaler.screenMatchMode = CanvasScaler.ScreenMatchMode.MatchWidthOrHeight;
|
||||
scaler.matchWidthOrHeight = 0f;
|
||||
}
|
||||
}
|
||||
|
||||
private static float ResolveCanvasPlaneDistance(Camera camera)
|
||||
{
|
||||
if (camera == null)
|
||||
{
|
||||
return DefaultCanvasPlaneDistance;
|
||||
}
|
||||
|
||||
float minDistance = camera.nearClipPlane + 0.05f;
|
||||
float maxDistance = camera.farClipPlane - 0.05f;
|
||||
if (maxDistance <= minDistance)
|
||||
{
|
||||
return minDistance;
|
||||
}
|
||||
|
||||
return Mathf.Clamp(DefaultCanvasPlaneDistance, minDistance, maxDistance);
|
||||
}
|
||||
|
||||
private void TryEnsureUiEventSubscribed()
|
||||
{
|
||||
if (_uiEventSubscribed || GameEntry.Event == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GameEntry.Event.Subscribe(OpenUIFormSuccessEventArgs.EventId, OnUIFormChanged);
|
||||
GameEntry.Event.Subscribe(CloseUIFormCompleteEventArgs.EventId, OnUIFormChanged);
|
||||
_uiEventSubscribed = true;
|
||||
_canvasCacheDirty = true;
|
||||
}
|
||||
|
||||
private void UnsubscribeUiEvents()
|
||||
{
|
||||
if (!_uiEventSubscribed || GameEntry.Event == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GameEntry.Event.Unsubscribe(OpenUIFormSuccessEventArgs.EventId, OnUIFormChanged);
|
||||
GameEntry.Event.Unsubscribe(CloseUIFormCompleteEventArgs.EventId, OnUIFormChanged);
|
||||
_uiEventSubscribed = false;
|
||||
}
|
||||
|
||||
private void OnUIFormChanged(object sender, GameEventArgs e)
|
||||
{
|
||||
_canvasCacheDirty = true;
|
||||
}
|
||||
|
||||
private void UpdateMaskLayout()
|
||||
{
|
||||
if (!_enableBlackMask)
|
||||
{
|
||||
SetMaskVisible(false, false);
|
||||
return;
|
||||
}
|
||||
|
||||
EnsureMaskObjects();
|
||||
if (_maskCanvas == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
float horizontalPadding = Mathf.Max(0f, (1f - _targetViewport.width) * 0.5f * _cachedScreenWidth);
|
||||
float verticalPadding = Mathf.Max(0f, (1f - _targetViewport.height) * 0.5f * _cachedScreenHeight);
|
||||
|
||||
bool showVerticalMask = horizontalPadding > 0.5f;
|
||||
bool showHorizontalMask = verticalPadding > 0.5f;
|
||||
|
||||
SetMaskVisible(showVerticalMask, showHorizontalMask);
|
||||
if (showVerticalMask)
|
||||
{
|
||||
SetVerticalMaskRect(_leftMask, true, horizontalPadding);
|
||||
SetVerticalMaskRect(_rightMask, false, horizontalPadding);
|
||||
}
|
||||
|
||||
if (showHorizontalMask)
|
||||
{
|
||||
SetHorizontalMaskRect(_topMask, true, verticalPadding);
|
||||
SetHorizontalMaskRect(_bottomMask, false, verticalPadding);
|
||||
}
|
||||
}
|
||||
|
||||
private void EnsureMaskObjects()
|
||||
{
|
||||
if (_maskCanvas != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GameObject maskRoot = new GameObject(
|
||||
"ResolutionMask",
|
||||
typeof(RectTransform),
|
||||
typeof(Canvas),
|
||||
typeof(CanvasScaler),
|
||||
typeof(GraphicRaycaster));
|
||||
maskRoot.transform.SetParent(transform, false);
|
||||
|
||||
_maskCanvas = maskRoot.GetComponent<Canvas>();
|
||||
_maskCanvas.renderMode = RenderMode.ScreenSpaceOverlay;
|
||||
_maskCanvas.overrideSorting = true;
|
||||
_maskCanvas.sortingOrder = short.MaxValue;
|
||||
|
||||
CanvasScaler scaler = maskRoot.GetComponent<CanvasScaler>();
|
||||
scaler.uiScaleMode = CanvasScaler.ScaleMode.ConstantPixelSize;
|
||||
scaler.scaleFactor = 1f;
|
||||
|
||||
GraphicRaycaster raycaster = maskRoot.GetComponent<GraphicRaycaster>();
|
||||
raycaster.enabled = false;
|
||||
|
||||
RectTransform rootRect = maskRoot.GetComponent<RectTransform>();
|
||||
rootRect.anchorMin = Vector2.zero;
|
||||
rootRect.anchorMax = Vector2.one;
|
||||
rootRect.anchoredPosition = Vector2.zero;
|
||||
rootRect.sizeDelta = Vector2.zero;
|
||||
|
||||
_leftMask = CreateMaskRect("LeftMask", rootRect);
|
||||
_rightMask = CreateMaskRect("RightMask", rootRect);
|
||||
_topMask = CreateMaskRect("TopMask", rootRect);
|
||||
_bottomMask = CreateMaskRect("BottomMask", rootRect);
|
||||
}
|
||||
|
||||
private static RectTransform CreateMaskRect(string maskName, Transform parent)
|
||||
{
|
||||
GameObject maskObject = new GameObject(maskName, typeof(RectTransform), typeof(Image));
|
||||
maskObject.transform.SetParent(parent, false);
|
||||
|
||||
Image image = maskObject.GetComponent<Image>();
|
||||
image.color = Color.black;
|
||||
image.raycastTarget = false;
|
||||
|
||||
return maskObject.GetComponent<RectTransform>();
|
||||
}
|
||||
|
||||
private void SetMaskVisible(bool showVerticalMask, bool showHorizontalMask)
|
||||
{
|
||||
if (_maskCanvas == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
bool visible = showVerticalMask || showHorizontalMask;
|
||||
_maskCanvas.enabled = visible;
|
||||
|
||||
if (_leftMask != null)
|
||||
{
|
||||
_leftMask.gameObject.SetActive(showVerticalMask);
|
||||
}
|
||||
|
||||
if (_rightMask != null)
|
||||
{
|
||||
_rightMask.gameObject.SetActive(showVerticalMask);
|
||||
}
|
||||
|
||||
if (_topMask != null)
|
||||
{
|
||||
_topMask.gameObject.SetActive(showHorizontalMask);
|
||||
}
|
||||
|
||||
if (_bottomMask != null)
|
||||
{
|
||||
_bottomMask.gameObject.SetActive(showHorizontalMask);
|
||||
}
|
||||
}
|
||||
|
||||
private static void SetVerticalMaskRect(RectTransform maskRect, bool isLeft, float width)
|
||||
{
|
||||
if (maskRect == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
maskRect.anchorMin = new Vector2(isLeft ? 0f : 1f, 0f);
|
||||
maskRect.anchorMax = new Vector2(isLeft ? 0f : 1f, 1f);
|
||||
maskRect.pivot = new Vector2(isLeft ? 0f : 1f, 0.5f);
|
||||
maskRect.anchoredPosition = Vector2.zero;
|
||||
maskRect.sizeDelta = new Vector2(width, 0f);
|
||||
}
|
||||
|
||||
private static void SetHorizontalMaskRect(RectTransform maskRect, bool isTop, float height)
|
||||
{
|
||||
if (maskRect == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
maskRect.anchorMin = new Vector2(0f, isTop ? 1f : 0f);
|
||||
maskRect.anchorMax = new Vector2(1f, isTop ? 1f : 0f);
|
||||
maskRect.pivot = new Vector2(0.5f, isTop ? 1f : 0f);
|
||||
maskRect.anchoredPosition = Vector2.zero;
|
||||
maskRect.sizeDelta = new Vector2(0f, height);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 975347a3464f1f74e938981a2fc4127e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -92,8 +92,8 @@ namespace Procedure
|
||||
// LoadDictionary("Default");
|
||||
|
||||
// Preload fonts
|
||||
LoadFont("MainFont");
|
||||
LoadTMPFont("MainTMPFont");
|
||||
LoadFont("simfang");
|
||||
LoadTMPFont("simfangTMP");
|
||||
|
||||
LoadSetting();
|
||||
}
|
||||
@@ -297,4 +297,4 @@ namespace Procedure
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,16 +32,16 @@ namespace Procedure
|
||||
{
|
||||
base.OnEnter(procedureOwner);
|
||||
|
||||
//InitializeProcedureState();
|
||||
//GameEntry.Dialog.Init(1);
|
||||
GameEntry.Dialog.Init(1);
|
||||
|
||||
//GameEntry.Dialog.StartDialog(1001);
|
||||
//GameEntry.Dialog.StartDialog(1002);
|
||||
AIChatFormContext context = new AIChatFormContext();
|
||||
GameEntry.Dialog.StartDialog(1002);
|
||||
|
||||
AIChatFormController controller = new AIChatFormController();
|
||||
context.Controller = controller;
|
||||
controller.OpenUI(context);
|
||||
// AIChatFormContext context = new AIChatFormContext();
|
||||
//
|
||||
// AIChatFormController controller = new AIChatFormController();
|
||||
// context.Controller = controller;
|
||||
// controller.OpenUI(context);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -154,4 +154,4 @@ namespace Procedure
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,10 +57,10 @@ namespace UI
|
||||
float targetAlpha = _currentWindowAlpha switch
|
||||
{
|
||||
DialogWindowAlpha.None => 1,
|
||||
DialogWindowAlpha.Low => 0.75f,
|
||||
DialogWindowAlpha.Medium => 0.5f,
|
||||
DialogWindowAlpha.High => 0.25f,
|
||||
_ => 0.5f
|
||||
DialogWindowAlpha.Low => 0.95f,
|
||||
DialogWindowAlpha.Medium => 0.8f,
|
||||
DialogWindowAlpha.High => 0.65f,
|
||||
_ => 0.9f
|
||||
};
|
||||
|
||||
if (_dialogBgImages.Length == 0)
|
||||
@@ -314,4 +314,4 @@ namespace UI
|
||||
rectTransform.anchoredPosition = anchoredPosition;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace UI
|
||||
{
|
||||
public class SelectableItem : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
|
||||
{
|
||||
[SerializeField] private Image _bgImage;
|
||||
[SerializeField] private GameObject _bgImage;
|
||||
|
||||
[SerializeField] private float _fadeDuration;
|
||||
|
||||
@@ -24,11 +24,7 @@ namespace UI
|
||||
{
|
||||
KillFadeSequence();
|
||||
|
||||
if (_allowFade)
|
||||
{
|
||||
_fadeSequence = DOTween.Sequence();
|
||||
_fadeSequence.Append(_bgImage.DOFade(1, _fadeDuration));
|
||||
}
|
||||
_bgImage.SetActive(true);
|
||||
|
||||
_onSelect.Invoke();
|
||||
}
|
||||
@@ -37,11 +33,7 @@ namespace UI
|
||||
{
|
||||
KillFadeSequence();
|
||||
|
||||
if (_allowFade)
|
||||
{
|
||||
_fadeSequence = DOTween.Sequence();
|
||||
_fadeSequence.Append(_bgImage.DOFade(0, _fadeDuration));
|
||||
}
|
||||
_bgImage.SetActive(false);
|
||||
|
||||
_onDeselect.Invoke();
|
||||
}
|
||||
@@ -54,4 +46,4 @@ namespace UI
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using Definition.DataStruct;
|
||||
using Definition.Enum;
|
||||
using Event;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityGameFramework.Runtime;
|
||||
@@ -10,14 +9,10 @@ namespace UI
|
||||
{
|
||||
public class SettingForm : UGuiForm
|
||||
{
|
||||
[SerializeField] private Transform _navigate;
|
||||
|
||||
[SerializeField] private Image[] _navigateButtonImages;
|
||||
|
||||
[SerializeField] private TMP_Text[] _navigateButtonTexts;
|
||||
|
||||
[SerializeField] private Color _darkColor;
|
||||
|
||||
[SerializeField] private Color _brightColor;
|
||||
|
||||
[SerializeField] private Slider _bgmVolumeSlider;
|
||||
|
||||
[SerializeField] private Slider _seVolumeSlider;
|
||||
@@ -105,10 +100,12 @@ namespace UI
|
||||
Log.Error("NavigateButtonClick index is out of range.");
|
||||
}
|
||||
|
||||
if (_navigateButtonImages[0] == null)
|
||||
_navigateButtonImages[0] = _navigate.Find("SoundButton")?.GetComponent<Image>();
|
||||
|
||||
for (int i = 0; i < _navigateButtonImages.Length; i++)
|
||||
{
|
||||
_navigateButtonImages[i].color = i != index ? _brightColor : _darkColor;
|
||||
_navigateButtonTexts[i].color = i != index ? _darkColor : _brightColor;
|
||||
_navigateButtonImages[i].enabled = i == index;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,4 +133,4 @@ namespace UI
|
||||
_controller.CloseUI();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user