当前位置: 首页 > news >正文

深圳做网站制作广告设计设计

深圳做网站制作,广告设计设计,网站开发人员招募费用,dedecms 一键更新网站一.SuperScrollView插件概述 UGUI SUPER SCROLLVIEW基于UGUI ScrollRect提供了易于定制的滚动浏览量。这是一组C#脚本,可帮助您创建所需的ScrollView。它非常强大且针对性能高度优化。 此插件是收费的,在AssetStore可以下载 SuperScrollVie…

一.SuperScrollView插件概述

UGUI SUPER SCROLLVIEW基于UGUI ScrollRect提供了易于定制的滚动浏览量。这是一组C#脚本,可帮助您创建所需的ScrollView。它非常强大且针对性能高度优化。

此插件是收费的,在AssetStore可以下载

SuperScrollView应该掌握到什么程度?

  • 1.使用时知道Editor中怎么设置,脚本中逻辑怎么写
  • 2.LoopListView2, LoopGridView and LoopStaggeredGridView 这3个核心组件分别在什么情况使用
  • 3.会使用脚本中的公有方法

二.SuperScrollView安装

将unitypackage包拖入Asset目录完成导入,生成SuperScrollView目录,包含了Demo,Editor和Scripts三个目录,还有一个很有帮助的文档DocumentV2_4,如下图所示:

三.官方文档总结提炼(快速入门)

3.1 概述

SuperScrollView中有3个核心组件: LoopListView2 , LoopGridView and LoopStaggeredGridView,他们都附加到ScrollRect组件所在的gameObject上,他们帮助ScrollRect实现高性能任意数量的item和节省内存。
实现原理上总的来说,使用内存池,监听滚动事件,实现了item的回收和复用,自动设置了每个item的位置。

3.2 LoopListView2组件

3.2.1 LoopListView2 Inspector Settings

Size:每个Item可以有不同的Prefab,Size指Item使用的Prefab总数

ElementX:每个Item有4个参数,当展开Element0后,可以看到有2个Element0,下面的Element0下面还有4个属性,以改变Padding为例,改变MPading和改变ItemPadding是一样的,这里推荐直接改ItemPadding,下面之所以多了4个属性可能是因为XPosOffset是自适应的属性

当Item有多个prefab时,需要添加多个Element

eg:一个排行榜有多个页签,切换页签时item不一样,这种情况需要添加多个Element

ItemPrefab:该Item使用gameObject的引用

ItemPadding:和下个Item的间距

XPosOffset:ScrollView最左侧到Item最左侧的间距

InitCreateCount:该Item对象池初始数量(可以填0,不知道为什么要手动设置,官方没有说)

SupportScrollbar:使用ScrollBar时勾上

ItemSnapEnable: 启用后,当滚动结束时,Item将被吸附(Snap)到预设的位置

ItemSnapPivot:给Item定义一个吸附轴心点,控制Item被吸附的位置

ViewPortSnapPivot:给ViewPort定义一个吸附轴心点,控制ViewPort吸附Item的位置

在上图中,ViewPortSnapPivot的Y设为1,代表ViewPort顶部将吸附item

ItemSnapPivot的Y设为0.5表示item中部将被吸附,滚动效果符合预期

ArrangeType:滚动方向,有4种选择

3.2.2 LoopListView2 Example

下文给出一个简化的LoopListView2 Example,可以取来作为快速开发的基础代码

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;namespace SuperScrollView
{public class ItemData1{public string itemName;public string itemDes;public ItemData1(string name, string des){itemName = name;itemDes = des;}}public class TopToBottomDemoScript : MonoBehaviour{private LoopListView2 mLoopListView;private int itemNum = 15;List<ItemData1> ssvData = new List<ItemData1>();void Start(){mLoopListView = GetComponent<LoopListView2>();for (int i = 0; i < itemNum; i++){ItemData1 data = new ItemData1("name"+i, "des"+i);ssvData.Add(data);}mLoopListView.InitListView(itemNum, OnGetItemByIndex);}LoopListViewItem2 OnGetItemByIndex(LoopListView2 listView, int index){if (index < 0 || index >= itemNum){return null;}ItemData1 itemData = ssvData[index];if(itemData == null){return null;}LoopListViewItem2 item = listView.NewListViewItem("ItemPrefab1");ListItemX itemScript = item.GetComponent<ListItemX>();if (item.IsInitHandlerCalled == false){item.IsInitHandlerCalled = true;itemScript.Init();}itemScript.UpdateItemUI(itemData,index);return item;}}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;namespace SuperScrollView
{public class ListItemX : MonoBehaviour{private Text mNameText;private Text mDescText;int mItemDataIndex = -1;public void Init(){mNameText = transform.Find("TextName").GetComponent<Text>();mDescText = transform.Find("TextDesc2").GetComponent<Text>();}public void UpdateItemUI(ItemData1 itemData, int itemIndex){mItemDataIndex = itemIndex;mNameText.text = itemData.itemName;mDescText.text = itemData.itemDes;}}
}

3.2.3 LoopListView2常用API

1.InitListView

LoopListView2组件的初始化方法

public void InitListView(int itemTotalCount,System.Func<LoopListView2, int, LoopListViewItem2> onGetItemByIndex,LoopListViewInitParam initParam = null)

2.NewListViewItem

用来获取一个从参数itemPrefabName克隆的新item,通常在onGetItemByIndex内部调用

public LoopListViewItem2 NewListViewItem(string itemPrefabName)

3.SetListItemCount

在运行时设置item数量

public void SetListItemCount(int itemCount, bool resetPos = true)

4.RefreshAllShownItem

刷新当前可视的item,经常在SetListItemCount之后调用,然而不是每次都需要调用RefreshAllShownItem。

必须调用的情形:当前显示的N-M个节点,在数据变化后N-M个节点的数据也变化了,则应调用RefreshAllShownItem

public void RefreshAllShownItem()

5.MovePanelToItemIndex

以从上至下的排列方式为例,该方法将移动Content直到itemIndex所在的item的上方和视口的上方对齐

public void MovePanelToItemIndex(int itemIndex, float offset)

6.OnItemSizeChanged

 For a vertical scrollrect, when a visible item’s height changed at runtime, then this method should be called to let the LoopListView2 component reposition all visible items’ position

public void OnItemSizeChanged(int itemIndex)

3.3 LoopGridView组件

3.3.1 LoopGridView Inspector Settings

ItemPrefabList:同LoopListView2

GridFixedType:有两个选项ColumnCountFixed or RowCountFixed,即列固定或者行固定RowCount/ColumnCount: if GridFixedType is ColumnCountFixed, then here you wouldset the column countof the GridView; if GridFixedType is RowCountFixed, then here you wouldset the row countof the GridView

Padding:the space between the items and the viewport

ItemSize: the size of items. If the x or y is set to 0, then the ItemSize would be auto set the size of
the first item of the ItemPrefabList when the LoopGridView component is inited.
ItemPadding: the amount of spacing between each item in the GridView.
RecycleDistance: how much distance an item leaves the viewport when the item would be
recycled.
ItemSnapEnable :同LoopListView2
ItemSnapPivot:同LoopListView2
ViewPortSnapPivot:同LoopListView2
ArrangeType :同LoopListView2

3.3.2 LoopGridView Example

下文给出一个简化的LoopGridView Example,可以取来作为快速开发的基础代码,item上脚本ListItemX同LoopListView2

using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using UnityEditorInternal.VersionControl;
using UnityEngine;
using UnityEngine.UI;namespace SuperScrollView
{public class ItemData1{public string itemName;public string itemDes;public ItemData1(string name, string des){itemName = name;itemDes = des;}}public class GridViewDemoScript2 : MonoBehaviour{public LoopGridView mLoopGridView;private int itemNum = 15;List<ItemData1> ssvData = new List<ItemData1>();// Use this for initializationvoid Start(){for (int i = 0; i < itemNum; i++){ItemData1 data = new ItemData1("name" + i, "des" + i);ssvData.Add(data);}mLoopGridView.InitGridView(ssvData.Count, OnGetItemByRowColumn);}LoopGridViewItem OnGetItemByRowColumn(LoopGridView gridView, int itemIndex,int row,int column){if (itemIndex < 0 || itemIndex >= ssvData.Count){return null;}ItemData1 itemData = ssvData[itemIndex];if (itemData == null){return null;}LoopGridViewItem item = gridView.NewListViewItem("ItemPrefab0");ListItemX itemScript = item.GetComponent<ListItemX>();if (item.IsInitHandlerCalled == false){item.IsInitHandlerCalled = true;itemScript.Init();}itemScript.UpdateItemUI(itemData, itemIndex, row, column);return item;}}
}

3.3.3 LoopGridView常用API

1. InitGridView

InitGridView组件的初始化方法;类似LoopListView2

 public void InitGridView(int itemTotalCount, System.Func<LoopGridView,int,int,int, LoopGridViewItem> onGetItemByRowColumn, LoopGridViewSettingParam settingParam = null,LoopGridViewInitParam initParam = null)

2.NewListViewItem

同LoopListView2

3.SetListItemCount

同LoopListView2

4.RefreshAllShownItem

同LoopListView2

5.MovePanelToItemByRowColumn

类似LoopListView2

public void MovePanelToItemByRowColumn(int row,int column, float offsetX = 0,float offsetY = 0)

http://www.dtcms.com/a/450909.html

相关文章:

  • 网站目录程序网站开发的报告书
  • 防盗报警网站建设网站推广费用入什么科目
  • 金融公司 网站开发网址大全wordpress
  • 烟台哪里做网站好万能视频下载神器
  • 设计营销型网站域名海口网约车从业资格证
  • 稳压电源和开关电源
  • 长春仿站定制模板建站电商网站维护费用
  • 怎么做学校网站宜昌市水利建设工程协会网站
  • 网站推广计划书范文500字南充网站建设公司
  • 学生如何自己做网站济南网站建设选搜点网络
  • 网站开发的未来展望噼里啪啦免费观看高清
  • 开平网站开发海外医疗手机网站建设
  • 提供网站建设案例海口h5公司
  • 深度学习算法
  • 品牌创意型网站开发网站关键词
  • 博物馆网站建设目的网站是怎么做优化
  • 《离散数学》:构筑数字世界的思维基石
  • springboot基于Java Web天气预报管理系统设计与实现(代码+数据库+LW)
  • 福州网页模板建站wordpress创建搜索页面
  • 网页设计站点网站建设相关标准
  • 网站没有备案做竞价吗购物网站如何做推广
  • 合肥大型网站制wordpress 酒
  • 福建省建设厅招标网站百度网址大全旧版
  • 用vs怎么做网站的导航深圳市公司网站建设公司
  • 太原营销型网站建设公司微网站开发商
  • 网站项目建设的定义wordpress 前台登录插件
  • 淘宝客cms网站怎么做网站做地域屏蔽
  • 医疗网站建设及优化方案如何自建企业网站
  • Python在一个文件夹下启动Python虚拟环境
  • 语言科目学习与记忆技巧 (英语,其它语)