团结实现3 d循环滚动效果的方法

  介绍

这篇文章主要介绍团结实现3 d循环滚动效果的方法,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!

具体内容如下

团结实现3 d循环滚动效果的方法

然后通过SetDepthAndPosition这个方法,实现图片的空间空间展开

团结实现3 d循环滚动效果的方法

团结实现3 d循环滚动效果的方法

Z轴和Y轴系数是一样的

经过上面设置,空间就摆开了

团结实现3 d循环滚动效果的方法

using  UnityEngine;   using  System.Collections;   using  System.Collections.Generic;      时间:public  class  SelectRole  MonoBehaviour  {   ,public  GameObject  rolesObj;   ,private  int  _half =, 0;//一侧的卡片数   ,private  int  _movX =, 150;//X轴移动距离   ,private  int  _movY =, 50;//Y轴移动距离   ,private  int  _movZ =, 60;//Z轴移动距离   ,private  int  count =, 3;//组件数   ,private  List _roleList =, new  List ();      ,//Use 却;能够for 初始化   ,void  Start  (), {//加才能载图片   对象[],才能textureList =, (Object []) Resources.LoadAll (“Pictures");      int 才能;maxDepth =, textureList.Length  %, 2,==, 1, ?, textureList.Length /, 2, +, 1,:, textureList.Length /, 2;//最大深度   时间=_half 才能;maxDepth;,,      for 才能;(int 小姐:=,0;,小姐:& lt;, textureList.Length;,我+ +)   ,,{,,   ,,//加载角色图片预设   ,,GameObject  role =,实例化(Resources.Load (“Role",, typeof (GameObject))), as  GameObject;,,,   ,,role.transform.parent =, rolesObj.transform;   ,,role.transform.localScale =, Vector3.one;      ,,EventDelegate.Add (role.GetComponent () .onChange ,, RoleToggleChange);      ,,RoleItem  item =, role.GetComponent ();,,,   ,,item.texture.mainTexture =, textureList[我],as 结构;      ,,//设置角色卡片排序命名   ,,role.name =, maxDepth.ToString ();   ,,if (小姐:祝辞,0)   ,,{   ,,,//奇数设置为右边,下标为正数   ,,,if (小姐:%,2,==,1)   ,,,{   ,,,,maxDepth——;   ,,,,role.name =, maxDepth.ToString ();   ,,,}   ,,,//偶数设置为左边,下标为负数   ,,,   ,,,{   ,,,,role.name =,“产生绯闻;,+,maxDepth.ToString ();   ,,,}   ,,}      ,,SetDepthAndPosition(项目,0,0);   ,,_roleList.Add(项);   ,,},   ,}         ,private  void  SetDepthAndPosition (RoleItem 角色,int  dir, int 指数)   ,{   int 才能;indexDepth =, 0;//左才能右移动后,重新排序命名   if 才能;(dir  !=, 0)   {才能   ,,if (指数* dir 祝辞,_half )   ,,,indexDepth =, -dir  *, (_half 作用;1);   其他的,,   ,,,indexDepth =, index 祝辞,1,,,,index  & lt;, 1, ?, dir :,指数;   ,,role.name =, indexDepth.ToString (),,   ,,},   其他的才能   {才能   ,,indexDepth =, int.Parse (role.name);   ,,}      TweenPosition 才能;tp =, role.GetComponent ();   int 才能;x =, indexDepth  & lt;, 0, ?, - (+ _half  indexDepth), *, _movX :, (_half 作用;indexDepth), *, _movX;   时间=indexDepth 才能;System.Math.Abs (indexDepth);   tp.to 才能=,new  Vector3 (x), (_half 作用;indexDepth), *, _movY,, (_half 作用;indexDepth), *, _movZ);         时间=role.bg.depth 才能;count  *, indexDepth;   role.active.depth 才能=,1,+,count  *, indexDepth;   时间=role.texture.depth 才能;2,+,count  *, indexDepth;,,      role.GetComponent<才能;UIToggle> () .value =, indexDepth ==, _half  ?,真的:假;   tp.PlayForward才能();   ,}      ,///& lt; summary>   ,///左边   ,///& lt;/summary>   ,public  void  LeftClick ()   ,{   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null

团结实现3 d循环滚动效果的方法