修复BUG

This commit is contained in:
MuHua-123
2025-09-22 14:27:21 +08:00
parent c17af4d74b
commit f4a07224aa
4 changed files with 20 additions and 9 deletions
@@ -1,8 +1,6 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False"> <ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
<ui:Template name="LoginPage" src="project://database/Assets/UI%20Toolkit/GamePage/LoginPage/LoginPage.uxml?fileID=9197481963319205126&amp;guid=7ebceaef0e3991040bf96648c85589a4&amp;type=3#LoginPage" />
<ui:Template name="BannerTip" src="project://database/Assets/UI%20Toolkit/GamePopup/BannerTip/BannerTip.uxml?fileID=9197481963319205126&amp;guid=e4a01fc5cb705fe4c9bedf1d0c5df107&amp;type=3#BannerTip" /> <ui:Template name="BannerTip" src="project://database/Assets/UI%20Toolkit/GamePopup/BannerTip/BannerTip.uxml?fileID=9197481963319205126&amp;guid=e4a01fc5cb705fe4c9bedf1d0c5df107&amp;type=3#BannerTip" />
<Style src="project://database/Assets/UI%20Toolkit/Document/Document.uss?fileID=7433441132597879392&amp;guid=9205939af30a4394f8f2e34232b27890&amp;type=3#Document" /> <Style src="project://database/Assets/UI%20Toolkit/Document/Document.uss?fileID=7433441132597879392&amp;guid=9205939af30a4394f8f2e34232b27890&amp;type=3#Document" />
<ui:Instance template="LoginPage" name="LoginPage" class="document-page document-page-hide" />
<ui:VisualElement name="Window" picking-mode="Ignore" class="document-page" style="flex-grow: 1;" /> <ui:VisualElement name="Window" picking-mode="Ignore" class="document-page" style="flex-grow: 1;" />
<ui:VisualElement name="Popup" picking-mode="Ignore" class="document-page" style="flex-grow: 1;"> <ui:VisualElement name="Popup" picking-mode="Ignore" class="document-page" style="flex-grow: 1;">
<ui:Instance template="BannerTip" name="BannerTip" class="document-page document-page-hide" /> <ui:Instance template="BannerTip" name="BannerTip" class="document-page document-page-hide" />
@@ -71,9 +71,16 @@ namespace MuHua {
} }
/// <summary> 视图滚轮滑动 </summary> /// <summary> 视图滚轮滑动 </summary>
private void ViewportWheel(WheelEvent evt) { private void ViewportWheel(WheelEvent evt) {
float x = Mathf.Clamp(evt.delta.x, -1, 1); float maxWidth = Viewport.resolvedStyle.width - Container.resolvedStyle.width;
float y = Mathf.Clamp(evt.delta.y, -1, 1); float minWidth = Mathf.Min(Viewport.resolvedStyle.width, Container.resolvedStyle.width);
UpdateValue(new Vector2(value.x - x, value.y - y)); float x = evt.delta.x * minWidth / maxWidth;
float maxHeight = Viewport.resolvedStyle.height - Container.resolvedStyle.height;
float minHeight = Mathf.Min(Viewport.resolvedStyle.height, Container.resolvedStyle.height);
float y = evt.delta.y * minHeight / maxHeight;
value = value - new Vector2(x, y);
UpdateValue(value);
} }
/// <summary> 拖拽按下 </summary> /// <summary> 拖拽按下 </summary>
private void DraggerDown(PointerDownEvent evt) { private void DraggerDown(PointerDownEvent evt) {
@@ -76,8 +76,11 @@ namespace MuHua {
} }
/// <summary> 滚轮滑动 </summary> /// <summary> 滚轮滑动 </summary>
private void ViewportWheel(WheelEvent evt) { private void ViewportWheel(WheelEvent evt) {
float wheel = Mathf.Clamp(evt.delta.y, -1, 1); float maxHeight = Viewport.resolvedStyle.height - Container.resolvedStyle.height;
UpdateValue(value - wheel); float minHeight = Mathf.Min(Viewport.resolvedStyle.height, Container.resolvedStyle.height);
float y = evt.delta.y * minHeight / maxHeight;
value = value - y;
UpdateValue(value);
} }
/// <summary> 拖拽按下 </summary> /// <summary> 拖拽按下 </summary>
private void DraggerDown(PointerDownEvent evt) { private void DraggerDown(PointerDownEvent evt) {
@@ -76,8 +76,11 @@ namespace MuHua {
} }
/// <summary> 滚轮滑动 </summary> /// <summary> 滚轮滑动 </summary>
private void ViewportWheel(WheelEvent evt) { private void ViewportWheel(WheelEvent evt) {
float wheel = Mathf.Clamp(evt.delta.y, -1, 1); float maxHeight = Viewport.resolvedStyle.height - Container.resolvedStyle.height;
UpdateValue(value - wheel); float minHeight = Mathf.Min(Viewport.resolvedStyle.height, Container.resolvedStyle.height);
float y = evt.delta.y * minHeight / maxHeight;
value = value - y;
UpdateValue(value);
} }
/// <summary> 拖拽按下 </summary> /// <summary> 拖拽按下 </summary>
private void DraggerDown(PointerDownEvent evt) { private void DraggerDown(PointerDownEvent evt) {