From a5fa5fe56c330de4ed3eb2420390a37fa7c7ecfa Mon Sep 17 00:00:00 2001 From: MuHua-123 <136542559+MuHua-123@users.noreply.github.com> Date: Thu, 24 Apr 2025 10:51:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=BB=9A=E5=8A=A8=E5=88=97?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Runtime/ModuleUIPanel/UIScrollList.cs | 26 +++++++++++++++++++ .../ModuleUIPanel/UIScrollList.cs.meta | 11 ++++++++ .../Runtime/ModuleUIPanel/UIScrollView.cs | 8 +++--- 3 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 Packages/UITool/Runtime/ModuleUIPanel/UIScrollList.cs create mode 100644 Packages/UITool/Runtime/ModuleUIPanel/UIScrollList.cs.meta diff --git a/Packages/UITool/Runtime/ModuleUIPanel/UIScrollList.cs b/Packages/UITool/Runtime/ModuleUIPanel/UIScrollList.cs new file mode 100644 index 0000000..a6a12f8 --- /dev/null +++ b/Packages/UITool/Runtime/ModuleUIPanel/UIScrollList.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.UIElements; + +namespace MuHua { + /// + /// 滚动列表 + /// + public class UIScrollList : UIScrollView where T : ModuleUIItem { + + private ModuleUIItems Items;// UI项容器 + + public UIScrollList(VisualElement element, VisualElement canvas, VisualTreeAsset templateAsset, Func generate, + UIDirection direction = UIDirection.HorizontalAndVertical, + UIDirection sh = UIDirection.FromLeftToRight, + UIDirection sv = UIDirection.FromTopToBottom) : base(element, canvas, direction, sh, sv) { + Items = new ModuleUIItems(Container, templateAsset, generate); + } + /// 释放资源 + public void Release() => Items.Release(); + /// 创建UI项 + public void Create(List datas) => Items.Create(datas); + } +} diff --git a/Packages/UITool/Runtime/ModuleUIPanel/UIScrollList.cs.meta b/Packages/UITool/Runtime/ModuleUIPanel/UIScrollList.cs.meta new file mode 100644 index 0000000..2bc1ec8 --- /dev/null +++ b/Packages/UITool/Runtime/ModuleUIPanel/UIScrollList.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e2fb9b587b7ce5d4295f1bb0da1c8d70 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/UITool/Runtime/ModuleUIPanel/UIScrollView.cs b/Packages/UITool/Runtime/ModuleUIPanel/UIScrollView.cs index 5dc94e5..02f437d 100644 --- a/Packages/UITool/Runtime/ModuleUIPanel/UIScrollView.cs +++ b/Packages/UITool/Runtime/ModuleUIPanel/UIScrollView.cs @@ -29,8 +29,10 @@ namespace MuHua { public VisualElement ScrollerHorizontal => Q("ScrollerHorizontal"); public VisualElement ScrollerVertical => Q("ScrollerVertical"); - public UIScrollView(VisualElement element, VisualElement canvas, UIDirection direction = UIDirection.HorizontalAndVertical, - UIDirection sh = UIDirection.FromLeftToRight, UIDirection sv = UIDirection.FromTopToBottom) : base(element) { + public UIScrollView(VisualElement element, VisualElement canvas, + UIDirection direction = UIDirection.HorizontalAndVertical, + UIDirection sh = UIDirection.FromLeftToRight, + UIDirection sv = UIDirection.FromTopToBottom) : base(element) { this.canvas = canvas; this.direction = direction; @@ -79,7 +81,7 @@ namespace MuHua { } /// 更新状态 - public void Update() { + public virtual void Update() { horizontal.Update(); vertical.Update();