Unity UI組件ScrollRect實(shí)現(xiàn)無限滾動條
在游戲開發(fā)中經(jīng)常遇到滾動顯示的數(shù)據(jù),特別是商店商品 排行榜 .......等數(shù)據(jù)很多,每一條數(shù)據(jù)去加載一個(gè)UI來顯示顯然對內(nèi)存浪費(fèi)很大,這種情況處理一般就是用幾個(gè)顯示條可滾動循環(huán)顯示無限數(shù)據(jù)條。本篇介紹實(shí)現(xiàn)過程和大體思路以及可重用的滑動腳本InfinityGridLayoutGroup和MarketLayoutGroup數(shù)據(jù)管理刷新腳本。MarketElement類要看具體項(xiàng)目中具體數(shù)據(jù)結(jié)構(gòu)來設(shè)計(jì);僅供參考。
一 .總體流程
建一個(gè)循環(huán)滑動腳本 InfinityGridLayoutGroup類并且有刪除刷新功能;
一個(gè)數(shù)據(jù)管理刷新腳本如:MarketLayoutGroup(商店市場數(shù)據(jù)刷新管理器),繼承InfinityGridLayoutGroup類 并且在滑動 的時(shí)候給每條數(shù)據(jù)對象賦值顯示;
一個(gè)單數(shù)據(jù)對象MarketElement;
一個(gè)UI 用于顯示滑動;
1 .InfinityGridLayoutGroup類:
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using System.Collections.Generic;
[RequireComponent(typeof(GridLayoutGroup))]
[RequireComponent(typeof(ContentSizeFitter))]
public class InfinityGridLayoutGroup : MonoBehaviour
{
public int minAmount = 0;//實(shí)現(xiàn)無限滾動,需要的最少的child數(shù)量。屏幕上能看到的+一行看不到的,比如我在屏幕上能看到 2 行,每一行 2 個(gè)。則這個(gè)值為 2行*2個(gè) + 1 行* 2個(gè) = 6個(gè)。
public bool changePanel = false;//切換面板
public bool up = false;
RectTransform rectTransform;
GridLayoutGroup gridLayoutGroup;
ContentSizeFitter contentSizeFitter;
ScrollRect scrollRect;
List<RectTransform> children = new List<RectTransform>();
Vector2 startPosition;
public int amount = 0;
public delegate void UpdateChildrenCallbackDelegate(int index, Transform trans);
public UpdateChildrenCallbackDelegate updateChildrenCallback = null;
public int realIndex = -1;
int realIndexUp = -1; //從下往上;
#region // 改動
Vector2 gridLayoutSizeLast;
Vector2 gridLayoutPosLast;
Vector2 currentPos;
#endregion
public bool hasInit = false;
Vector2 gridLayoutSize;
Vector2 gridLayoutPos;
Dictionary<Transform, Vector2> childsAnchoredPosition = new Dictionary<Transform, Vector2>();
Dictionary<Transform, int> childsSiblingIndex = new Dictionary<Transform, int>();
// Use this for initialization
void Start()
{
StartCoroutine(InitChildren());
}
IEnumerator InitChildren()
{
yield return 0;
// Debug.Log("hasInit" + hasInit);
minAmount = transform.childCount;
if (!hasInit)
{
//childsAnchoredPosition.Clear();
//獲取Grid的寬度;
rectTransform = GetComponent<RectTransform>();
gridLayoutGroup = GetComponent<GridLayoutGroup>();
gridLayoutGroup.enabled = false;
contentSizeFitter = GetComponent<ContentSizeFitter>();
contentSizeFitter.enabled = false;
gridLayoutSizeLast = rectTransform.sizeDelta;
gridLayoutPos = rectTransform.anchoredPosition;
gridLayoutSize = rectTransform.sizeDelta;
// Debug.Log("<Color=Red>children</Color>---" + children.Count + "realIndex---" + realIndex);
//注冊ScrollRect滾動回調(diào);
scrollRect = transform.parent.GetComponent<ScrollRect>();
scrollRect.onValueChanged.AddListener((data) => { ScrollCallback(data); });
//獲取所有child anchoredPosition 以及 SiblingIndex;
for (int index = 0; index < transform.childCount; index++)
{
Transform child = transform.GetChild(index);
RectTransform childRectTrans = child.GetComponent<RectTransform>();
childsAnchoredPosition.Add(child, childRectTrans.anchoredPosition);
childsSiblingIndex.Add(child, child.GetSiblingIndex());
}
//Debug.Log("<Color=Blue>children</Color>---" + children.Count + "realIndex---" + realIndex);
}
else
{
//Debug.Log("gridLayoutPosLast--" + gridLayoutSizeLast.y);
rectTransform.anchoredPosition = new Vector2(gridLayoutPos.x, Vector2.zero.y);
// Debug.Log("current--" + currentPos.y);
rectTransform.sizeDelta = gridLayoutSize;
gridLayoutSizeLast = rectTransform.sizeDelta;
// Debug.Log("rectTransform.sizeDelta--" + rectTransform.sizeDelta.y);
children.Clear();
realIndex = -1;
realIndexUp = -1;
//children重新設(shè)置上下順序;
foreach (var info in childsSiblingIndex)
{
info.Key.SetSiblingIndex(info.Value);
}
//children重新設(shè)置anchoredPosition;
for (int index = 0; index < transform.childCount; index++)
{
Transform child = transform.GetChild(index);
RectTransform childRectTrans = child.GetComponent<RectTransform>();
if (childsAnchoredPosition.ContainsKey(child))
{
childRectTrans.anchoredPosition = childsAnchoredPosition[child];
}
else
{
Debug.LogError("childsAnchoredPosition no contain " + child.name);
}
}
}
//獲取所有child;
for (int index = 0; index < transform.childCount; index++)
{
Transform trans = transform.GetChild(index);
trans.gameObject.SetActive(true);
children.Add(transform.GetChild(index).GetComponent<RectTransform>());
//初始化前面幾個(gè);
UpdateChildrenCallback(children.Count - 1, transform.GetChild(index));
}
startPosition = rectTransform.anchoredPosition;
// Debug.Log("<Color=Red>children</Color>---"+ children.Count+ "realIndex---"+ realIndex);
realIndex = children.Count - 1;
ShowElement(realIndex);
//Debug.Log( scrollRect.transform.TransformPoint(Vector3.zero));
// Debug.Log(transform.TransformPoint(children[0].localPosition));
hasInit = true;
//如果需要顯示的個(gè)數(shù)小于設(shè)定的個(gè)數(shù);
for (int index = 0; index < minAmount; index++)
{
children[index].gameObject.SetActive(index < amount);
}
if (gridLayoutGroup.constraint == GridLayoutGroup.Constraint.FixedColumnCount)
{
//如果小了一行,則需要把GridLayout的高度減去一行的高度;
int row = (minAmount - amount) / gridLayoutGroup.constraintCount;
if (row > 0)
{
rectTransform.sizeDelta -= new Vector2(0, (gridLayoutGroup.cellSize.y + gridLayoutGroup.spacing.y) * row);
}
}
else
{
//如果小了一列,則需要把GridLayout的寬度減去一列的寬度;
int column = (minAmount - amount) / gridLayoutGroup.constraintCount;
if (column > 0)
{
rectTransform.sizeDelta -= new Vector2((gridLayoutGroup.cellSize.x + gridLayoutGroup.spacing.x) * column, 0);
}
}
//if (amount <= minAmount)
// scrollRect.enabled = false;
//else
// scrollRect.enabled = true;
}
void ScrollCallback(Vector2 data)
{
UpdateChildren();
}
void UpdateChildren()
{
// Debug.Log("當(dāng)前位置");
if (transform.childCount < minAmount)
{
return;
}
// Debug.Log("當(dāng)前位置" + rectTransform.anchoredPosition.y + "startPosition.y" + startPosition.y);
currentPos = rectTransform.anchoredPosition;
//Vector2 currentPos = rectTransform.anchoredPosition;
if (gridLayoutGroup.constraint == GridLayoutGroup.Constraint.FixedColumnCount)
{
float offsetY = currentPos.y - startPosition.y;
if (offsetY > 0)
{
//向上拉,向下擴(kuò)展;
{
if (realIndex >= amount - 1)
{
startPosition = currentPos;
return;
}
up = false;
float scrollRectUp = scrollRect.transform.TransformPoint(Vector3.zero).y;
Vector3 childBottomLeft = new Vector3(children[0].anchoredPosition.x, children[0].anchoredPosition.y - gridLayoutGroup.spacing.y - gridLayoutGroup.cellSize.y * 0.5f, 0f); //gridLayoutGroup.cellSize.y
float childBottom = transform.TransformPoint(childBottomLeft).y;
if (childBottom >= scrollRectUp)
{
Debug.Log("childBottom >= scrollRectUp");
//移動到底部;
for (int index = 0; index < gridLayoutGroup.constraintCount; index++)
{
children[index].SetAsLastSibling();
children[index].anchoredPosition = new Vector2(children[index].anchoredPosition.x, children[children.Count - 1].anchoredPosition.y - gridLayoutGroup.cellSize.y - gridLayoutGroup.spacing.y);
realIndex++;
if (realIndex > amount - 1)
{
children[index].gameObject.SetActive(false);
}
else
{
UpdateChildrenCallback(realIndex, children[index]);
}
}
ShowElement(realIndex);
//GridLayoutGroup 底部加長;
rectTransform.sizeDelta += new Vector2(0, gridLayoutGroup.cellSize.y + gridLayoutGroup.spacing.y);
gridLayoutSizeLast = rectTransform.sizeDelta;
// Debug.Log("<Color=Red>gridLayoutSizeLast.y</Color>" + gridLayoutSizeLast.y);
//更新child;
for (int index = 0; index < children.Count; index++)
{
children[index] = transform.GetChild(index).GetComponent<RectTransform>();
}
}
// Debug.Log("realIndex向上--" + realIndex);
}
}
else
{
//Debug.Log("Drag Down");
//向下拉,下面收縮;
if (realIndex + 1 <= children.Count)
{
startPosition = currentPos;
return;
}
RectTransform scrollRectTransform = scrollRect.GetComponent<RectTransform>();
Vector3 scrollRectAnchorBottom = new Vector3(0, -scrollRectTransform.rect.height - gridLayoutGroup.spacing.y, 0f);//- gridLayoutGroup.spacing.y
float scrollRectBottom = scrollRect.transform.TransformPoint(scrollRectAnchorBottom).y;
Vector3 childUpLeft = new Vector3(children[children.Count - 1].anchoredPosition.x, children[children.Count - 1].anchoredPosition.y + gridLayoutGroup.spacing.y * minAmount, 0f);//gridLayoutGroup.spacing.y realIndex-minAmount+1
float childUp = transform.TransformPoint(childUpLeft).y;
//Debug.Log("childUp----" + childUp + "scrollRectBottom---" + scrollRectBottom);
if (childUp < scrollRectBottom)
{
//Debug.Log("childUp < scrollRectBottom");
up = true;
//把底部的一行 移動到頂部
for (int index = 0; index < gridLayoutGroup.constraintCount; index++)
{
children[children.Count - 1 - index].SetAsFirstSibling();
children[children.Count - 1 - index].anchoredPosition = new Vector2(children[children.Count - 1 - index].anchoredPosition.x, children[0].anchoredPosition.y + gridLayoutGroup.cellSize.y + gridLayoutGroup.spacing.y);
children[children.Count - 1 - index].gameObject.SetActive(true);
UpdateChildrenCallback(realIndex - children.Count - index, children[children.Count - 1 - index]);
}
realIndex -= gridLayoutGroup.constraintCount;
ShowElement(realIndex);
//GridLayoutGroup 底部縮短;
//rectTransform.anchoredPosition = gridLayoutPos;
rectTransform.sizeDelta -= new Vector2(0, gridLayoutGroup.cellSize.y + gridLayoutGroup.spacing.y);
gridLayoutSizeLast = rectTransform.sizeDelta;
//Debug.Log("<Color=Red>gridLayoutSizeLast.y</Color>" + gridLayoutSizeLast.y);
//更新child;
for (int index = 0; index < children.Count; index++)
{
children[index] = transform.GetChild(index).GetComponent<RectTransform>();
}
}
// Debug.Log("realIndex向下--" + realIndex);
}
}
#region 左右滑動
else
{
float offsetX = currentPos.x - startPosition.x;
if (offsetX < 0)
{
//向左拉,向右擴(kuò)展;
{
if (realIndex >= amount - 1)
{
startPosition = currentPos;
return;
}
float scrollRectLeft = scrollRect.transform.TransformPoint(Vector3.zero).x;
Vector3 childBottomRight = new Vector3(children[0].anchoredPosition.x + gridLayoutGroup.cellSize.x, children[0].anchoredPosition.y, 0f);
float childRight = transform.TransformPoint(childBottomRight).x;
// Debug.LogError("childRight=" + childRight);
if (childRight <= scrollRectLeft)
{
//Debug.Log("childRight <= scrollRectLeft");
//移動到右邊;
for (int index = 0; index < gridLayoutGroup.constraintCount; index++)
{
children[index].SetAsLastSibling();
children[index].anchoredPosition = new Vector2(children[children.Count - 1].anchoredPosition.x + gridLayoutGroup.cellSize.x + gridLayoutGroup.spacing.x, children[index].anchoredPosition.y);
realIndex++;
if (realIndex > amount - 1)
{
children[index].gameObject.SetActive(false);
}
else
{
UpdateChildrenCallback(realIndex, children[index]);
}
}
if (realIndex >= 7)
//GridLayoutGroup 右側(cè)加長;
rectTransform.sizeDelta += new Vector2(gridLayoutGroup.cellSize.x + gridLayoutGroup.spacing.x, 0);
//更新child;
for (int index = 0; index < children.Count; index++)
{
children[index] = transform.GetChild(index).GetComponent<RectTransform>();
}
}
}
}
else
{
//Debug.Log("Drag Down");
//向右拉,右邊收縮;
if (realIndex + 1 <= children.Count)
{
startPosition = currentPos;
return;
}
RectTransform scrollRectTransform = scrollRect.GetComponent<RectTransform>();
Vector3 scrollRectAnchorRight = new Vector3(scrollRectTransform.rect.width + gridLayoutGroup.spacing.x, 0, 0f);
float scrollRectRight = scrollRect.transform.TransformPoint(scrollRectAnchorRight).x;
Vector3 childUpLeft = new Vector3(children[children.Count - 1].anchoredPosition.x, children[children.Count - 1].anchoredPosition.y, 0f);
float childLeft = transform.TransformPoint(childUpLeft).x;
if (childLeft >= scrollRectRight)
{
//Debug.LogError("childLeft > scrollRectRight");
//把右邊的一行 移動到左邊;
for (int index = 0; index < gridLayoutGroup.constraintCount; index++)
{
children[children.Count - 1 - index].SetAsFirstSibling();
children[children.Count - 1 - index].anchoredPosition = new Vector2(children[0].anchoredPosition.x - gridLayoutGroup.cellSize.x - gridLayoutGroup.spacing.x, children[children.Count - 1 - index].anchoredPosition.y);
children[children.Count - 1 - index].gameObject.SetActive(true);
UpdateChildrenCallback(realIndex - children.Count - index, children[children.Count - 1 - index]);
}
//GridLayoutGroup 右側(cè)縮短;
rectTransform.sizeDelta -= new Vector2(gridLayoutGroup.cellSize.x + gridLayoutGroup.spacing.x, 0);
//更新child;
for (int index = 0; index < children.Count; index++)
{
children[index] = transform.GetChild(index).GetComponent<RectTransform>();
}
realIndex -= gridLayoutGroup.constraintCount;
}
#endregion
}
}
// Debug.Log("realIndex--" + realIndex);
//Debug.Log("currentPos.y--" + currentPos.y + "rectTransform.sizeDelta---" + rectTransform.sizeDelta.y);
startPosition = currentPos;
gridLayoutPosLast = currentPos;
}
void UpdateChildrenCallback(int index, Transform trans)
{
if (updateChildrenCallback != null)
{
updateChildrenCallback(index, trans);
}
}
public virtual void ShowElement(int endIndex)
{
}
/// <summary>
/// 設(shè)置總的個(gè)數(shù);
/// </summary>
/// <param name="count"></param>
public void SetAmount(int count)
{
amount = count;
//如果切換面板
if (!changePanel)
{
//hasInit = false;
StartCoroutine(InitChildren());
changePanel = true;
}
else
{
// Debug.Log("currentPos.y--" + currentPos.y);
if (currentPos.y > 10)
{
如果需要顯示的個(gè)數(shù)小于設(shè)定的個(gè)數(shù);
//Debug.Log("minAmount--"+minAmount);
for (int index = 0; index < minAmount; index++)
{
children[index].gameObject.SetActive(index < amount);
}
//刪除操作
if (GameInstance.isDecrase)
{
if (realIndex > minAmount - 1)
{
realIndex--;
//把底部的一行 移動到頂部
for (int index = 0; index < gridLayoutGroup.constraintCount; index++)
{
children[children.Count - 1 - index].SetAsFirstSibling();
children[children.Count - 1 - index].anchoredPosition = new Vector2(children[children.Count - 1 - index].anchoredPosition.x, children[0].anchoredPosition.y + gridLayoutGroup.cellSize.y + gridLayoutGroup.spacing.y);
children[children.Count - 1 - index].gameObject.SetActive(true);
UpdateChildrenCallback(realIndex - children.Count - index, children[children.Count - 1 - index]);
}
//更新child;
for (int index = 0; index < children.Count; index++)
{
children[index] = transform.GetChild(index).GetComponent<RectTransform>();
}
}
GameInstance.isDecrase = false;//GameInstance類中bool變量控制條目刪除的刷新使用
currentPos = new Vector2(currentPos.x, currentPos.y - gridLayoutGroup.cellSize.y - gridLayoutGroup.spacing.y);
if (realIndex > minAmount - 1)
{
gridLayoutSizeLast = new Vector2(gridLayoutSizeLast.x, gridLayoutSizeLast.y - gridLayoutGroup.cellSize.y - gridLayoutGroup.spacing.y);
}
else
rectTransform.anchoredPosition = currentPos;
}
else
rectTransform.anchoredPosition = currentPos;
rectTransform.sizeDelta = gridLayoutSizeLast;
rectTransform.anchoredPosition = new Vector2(currentPos.x, currentPos.y);
startPosition = rectTransform.anchoredPosition;
ShowElement(realIndex);
}
else
{
StartCoroutine(InitChildren());
}
}
}
}
2.MarketLayoutGroup類:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MarketLayoutGroup : InfinityGridLayoutGroup
{
bool isNotOutRange = false;
//商店市場的可買的商品集合
private List<MarketGood> marketGoods;
//可出售到商店的商品集合
public List<SealGood> marketSeal;
//可要在商店加工的商品集合
private List<ExchangeGood> marketMake;
//重寫父類的調(diào)用循環(huán)刷新顯示
public override void ShowElement(int endIndex)
{
//獲取商店窗體對象
MarketActivity market = MainPanelContrller.Instance.presenter.MarketWindowsActivity[0] as MarketActivity;
//判斷當(dāng)前窗體默認(rèn)開啟的類型是否是可買的商品集合
if (market.current == CurrentPanel.Image_Buy)
{
//獲取可買商品的數(shù)據(jù)( GameInstance全局?jǐn)?shù)據(jù)儲存腳本)
marketGoods = GameInstance.marketGoods;
//判斷商品數(shù)
amount = marketGoods.Count;
//Debug.Log ("marketGoods--"+marketGoods.Count);
//endIndex為可見ui的最大下標(biāo)
isNotOutRange = endIndex < marketGoods.Count ? true : false;
//遍歷ui對象數(shù)目 判斷每一條ui應(yīng)該顯示的數(shù)據(jù) 并調(diào)用MarketElement賦值顯示。
for (int i = 0; i < transform.childCount; i++)
{
//獲取ui顯示對象
MarketElement presenter = transform.GetChild(i).GetComponent<MarketElement>();
//判斷并且賦值顯示
if (isNotOutRange)
{
//presenter.name.text = myGoodList[endIndex - minAmount + 1 + i].name;
presenter.SetData(marketGoods[endIndex - minAmount + 1 + i]);
}
else
{
if (endIndex - minAmount + 1 + i < marketGoods.Count)
{
presenter.SetData(marketGoods[endIndex - minAmount + 1 + i]);
}
else
{
MarketGood good = new MarketGood();
presenter.SetData(good);
}
}
}
}
else if (market.current == CurrentPanel.Image_Seal)
{
if (GameInstance.marketSeals == null)
return;
//Debug.Log("GameInstance.marketSeals" + GameInstance.marketSeals.Count);
// Debug.Log("marketSeal" + marketSeal);
marketSeal = GameInstance.marketSeals;
amount = marketSeal.Count;
isNotOutRange = endIndex < marketSeal.Count ? true : false;
for (int i = 0; i < transform.childCount; i++)
{
ElementSeal presenter = transform.GetChild(i).GetComponent<ElementSeal>();
if (isNotOutRange)
{
//Debug.Log("endIndex+" + endIndex);
//Debug.Log(endIndex - minAmount + 1 + i);
//presenter.name.text = myGoodList[endIndex - minAmount + 1 + i].name;
presenter.SetData(marketSeal[endIndex - minAmount + 1 + i]);
}
else
{
// Debug.Log(endIndex - minAmount + 1 + i);
if (endIndex - minAmount + 1 + i < marketSeal.Count)
{
presenter.SetData(marketSeal[endIndex - minAmount + 1 + i]);
}
else
{
SealGood _good = new SealGood();
presenter.SetData(_good);
}
}
}
}
else
{
//Debug.Log("當(dāng)前所在條數(shù)--" + realIndex);
//加工
marketMake = GameInstance.marketMakes;
amount = marketMake.Count;
isNotOutRange = endIndex < marketMake.Count ? true : false;
for (int i = 0; i < transform.childCount; i++)
{
MarketElement presenter = transform.GetChild(i).GetComponent<MarketElement>();
if (isNotOutRange)
{
//presenter.name.text = myGoodList[endIndex - minAmount + 1 + i].name;
presenter.SetData(marketMake[endIndex - minAmount + 1 + i]);
}
else
{
//Debug.Log ("marketGoods---"+marketGoods);
if (endIndex - minAmount + 1 + i < marketMake.Count)
{
presenter.SetData(marketMake[endIndex - minAmount + 1 + i]);
}
else
{
ExchangeGood good = new ExchangeGood();
presenter.SetData(good);
}
}
}
}
}
}
3.UI對象父類MarketElement:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MarketElement : MonoBehaviour
{
public virtual void SetData(ExchangeGood good) { }
public virtual void SetData(MarketGood good) { }
public virtual void SetData(SealGood good) { }
public virtual void SetData() { }
}
實(shí)現(xiàn)類:ElementMarket
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ElementMarket : MarketElement
{
private MarketGood _goodData;
[Header("物品框父物體")]
public Image good_BG;
public Text price;
public Text num;
public Text name;
public Text nameGoods;
public Button buy;
LocalizeData xml_data = new LocalizeData();
string config = LocalizeManager.Instance.GetCurrentLanguage();
public override void SetData(MarketGood good)
{
base.SetData(good);
if (good.goodsId == 0) return;
_goodData = good;
if (MainPanelContrller.Instance.openStyle == OpenMarketStyle.Skill)
{
GoodsInfoData myGood = new GoodsInfoData();
GameManager.Instance.allXmlData.GetXmlData<GoodsInfoData>(ConfigFilesName.GOODS_CONFIG, good.goodsId, ref myGood);
good_BG.transform.GetChild(0).GetComponent<Image>().sprite = SpriteManager.LoadAtlasSprite("Sprite/Item", "Item_" + myGood.Icon);
price.text = "x" + good.price.ToString();
nameGoods.text = myGood.Name;
// num.text = "x" + good.num;
// int trend = good.price - good.lastPrice;
//使用描述
name.text = myGood.Description;
//物品描述
num.text = myGood.Description_2;
}
else
{
//員外的
}
}
void OnEnable()
{
buy.onClick.AddListener(BuyBtn);
}
void OnDisable()
{
buy.onClick.RemoveAllListeners();
}
/// <summary>
/// 打開購買二級界面
/// </summary>
void BuyBtn()
{
Debug.Log("購買了資源商店:" + _goodData.goodsId + " 物品");
this.gameObject.transform.parent.GetComponent<MarketLayoutGroup>().changePanel = true;
Bundle bundle = new Bundle();
bundle.PutObject("marketGood", _goodData);
MainPanelContrller.Instance.presenter.MarketWindowsActivity[0].manager.PushWindow(typeof(BuyActivity), bundle);
}
}
4.UI:
滑動總UI scrollrect

滑動組件Grid MarketLayerGourp

滑動條 ElementMarket:

Ok 介紹到這里:ElementMarket 根據(jù)具體項(xiàng)目的數(shù)據(jù) 進(jìn)行調(diào)整,其他兩項(xiàng)都可以重用。
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
淺析C#?AsyncLocal如何在異步間進(jìn)行數(shù)據(jù)流轉(zhuǎn)
在異步編程中,處理異步操作之間的數(shù)據(jù)流轉(zhuǎn)是一個(gè)比較常用的操作,C#異步編程提供了一個(gè)強(qiáng)大的工具來解決這個(gè)問題,那就是AsyncLocal,下面我們就來看看AsyncLocal的原理和用法吧2023-08-08
C#實(shí)現(xiàn)對字符串進(jìn)行大小寫切換的方法
這篇文章主要介紹了C#實(shí)現(xiàn)對字符串進(jìn)行大小寫切換的方法,涉及C#操作字符串的技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-03-03
C#實(shí)現(xiàn)漂亮的數(shù)字時(shí)鐘效果
這篇文章主要介紹了C#實(shí)現(xiàn)漂亮的數(shù)字時(shí)鐘效果,涉及時(shí)間函數(shù)的應(yīng)用及繪圖的方法,需要的朋友可以參考下2014-10-10
C# winForm實(shí)現(xiàn)的氣泡提示窗口功能示例
這篇文章主要介紹了C# winForm實(shí)現(xiàn)的氣泡提示窗口功能,涉及C# winForm窗口屬性與設(shè)置相關(guān)操作技巧,需要的朋友可以參考下2018-03-03
C#使用iTextSharp將PDF轉(zhuǎn)成文本的方法
這篇文章主要介紹了C#使用iTextSharp將PDF轉(zhuǎn)成文本的方法,涉及C#操作pdf文件的相關(guān)技巧,需要的朋友可以參考下2015-05-05

