本文实例为大家分享了团结实现卡牌翻动效果展示的具体代码,供大家参考,具体内容如下
事实上这是项目需要,我改的一个代码,实际上就是利用统一的一些基础属性实现其效果。啥也不多说了,先上原代码:
///信贷YakaYocha太太///来自https://www.youtube.com/channel/UCHp8LZ_0-iCvl-5pjHATsgw///请捐赠:https://www.paypal.com/cgi-bin/webscr& # 63; cmd=_s-xclick& hosted_button_id=RJ8D9FRFQF9VS 使用UnityEngine.Events; 名称空间UnityEngine.UI.Extensions { [RequireComponent typeof (ScrollRect))) [AddComponentMenu(“布局/扩展/垂直照片卷轴”)) 公开课UIVerticalScroller: MonoBehaviour { 工具提示(“可滚动区域(内容期望ScrollRect)”)) 公共RectTransform _scrollingPanel; 工具提示(“元素填充内部照片卷轴”)) 公共GameObject [] _arrayOfElements; (工具提示(“中心”显示区域(放大的位置内容))) 公共RectTransform _center; [提示“选择项目中心>///信贷YakaYocha太太///来自https://www.youtube.com/channel/UCHp8LZ_0-iCvl-5pjHATsgw///请捐赠:https://www.paypal.com/cgi-bin/webscr& # 63; cmd=_s-xclick& hosted_button_id=RJ8D9FRFQF9VS 使用UnityEngine.Events; 名称空间UnityEngine.UI.Extensions { [RequireComponent typeof (ScrollRect))) [AddComponentMenu(“布局/扩展/垂直照片卷轴”)) 公开课UIVerticalScrollerMove: MonoBehaviour { 工具提示(“可滚动区域(内容期望ScrollRect)”)) 公共RectTransform _scrollingPanel;//展示面板 工具提示(“元素填充内部照片卷轴”)) 公共GameObject [] _arrayOfElements;//长度元素 (工具提示(“中心”显示区域(放大的位置内容))) 公共RectTransform _center;//位置 [提示“选择项目中心> 使用System.Collections; 使用System.Collections.Generic; 使用UnityEngine; 使用UnityEngine.UI; 使用UnityEngine.UI.Extensions; 公共类ScrollingCalendarTest: MonoBehaviour { 公共RectTransform monthsScrollingPanel; 公共GameObject monthsButtonPrefab; 私人GameObject [] monthsButtons; 公共RectTransform monthCenter; 私人int monthsSet; UIVerticalScrollerMove monthsVerticalScroller;//初始化几个月//生成预制体 私人空间InitializeMonths () { int[]个月=new int [12]; monthsButtons=new GameObject [months.Length]; for (int i=0;我& lt;months.Length;我+ +) { 弦月=" "; 个月[我]=我; GameObject克?(GameObject)实例化(monthsButtonPrefab新Vector3(我* 380,0,0),四元数。欧拉(新Vector3(0, 0, 0)))作为GameObject; clone.transform。SetParent (monthsScrollingPanel假); clone.transform。localScale=new Vector3 (1 1 1); 月=" +我; clone.GetComponentInChildren()。文本=月; clone.name=" Month_ " +个月[我]; clone.AddComponent (); monthsButtons[我]=克隆; } }//用它来初始化 公共空间清醒() { InitializeMonths ();//是的统一抱怨这但没关系。 monthsVerticalScroller=new UIVerticalScrollerMove (monthsScrollingPanel, monthsButtons monthCenter); monthsVerticalScroller.Start (); } 公共空间设置当前日期() {//monthsSet=int.Parse (inputFieldMonths.text) - 1; monthsVerticalScroller.SnapToElement (monthsSet); } 无效的更新() { monthsVerticalScroller.Update (); 字符串monthString=monthsVerticalScroller.GetResults (); } 公共空间MonthsScrollUp () { monthsVerticalScroller.ScrollLeft (); } 公共空间MonthsScrollDown () { monthsVerticalScroller.ScrollRight (); } } >之前 效果与引用:
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
团结实现卡牌翻动效果