增加滚动列表
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace MuHua {
|
||||
/// <summary>
|
||||
/// 滚动列表
|
||||
/// </summary>
|
||||
public class UIScrollList<T, Data> : UIScrollView where T : ModuleUIItem<Data> {
|
||||
|
||||
private ModuleUIItems<T, Data> Items;// UI项容器
|
||||
|
||||
public UIScrollList(VisualElement element, VisualElement canvas, VisualTreeAsset templateAsset, Func<Data, VisualElement, T> generate,
|
||||
UIDirection direction = UIDirection.HorizontalAndVertical,
|
||||
UIDirection sh = UIDirection.FromLeftToRight,
|
||||
UIDirection sv = UIDirection.FromTopToBottom) : base(element, canvas, direction, sh, sv) {
|
||||
Items = new ModuleUIItems<T, Data>(Container, templateAsset, generate);
|
||||
}
|
||||
/// <summary> 释放资源 </summary>
|
||||
public void Release() => Items.Release();
|
||||
/// <summary> 创建UI项 </summary>
|
||||
public void Create(List<Data> datas) => Items.Create(datas);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e2fb9b587b7ce5d4295f1bb0da1c8d70
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -29,8 +29,10 @@ namespace MuHua {
|
||||
public VisualElement ScrollerHorizontal => Q<VisualElement>("ScrollerHorizontal");
|
||||
public VisualElement ScrollerVertical => Q<VisualElement>("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 {
|
||||
}
|
||||
|
||||
/// <summary> 更新状态 </summary>
|
||||
public void Update() {
|
||||
public virtual void Update() {
|
||||
horizontal.Update();
|
||||
vertical.Update();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user