亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Unity實現(xiàn)3D循環(huán)滾動效果

 更新時間:2021年02月23日 16:48:23   作者:海濤高軟  
這篇文章主要為大家詳細(xì)介紹了Unity實現(xiàn)3D循環(huán)滾動效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了Unity實現(xiàn)3D循環(huán)滾動效果展示的具體代碼,供大家參考,具體內(nèi)容如下

然后通過SetDepthAndPosition這個方法,實現(xiàn)圖片的空間空間展開

Z軸和Y軸,系數(shù)是一樣的

經(jīng)過上面設(shè)置,空間就擺開了

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class SelectRole : MonoBehaviour {
 public GameObject rolesObj;
 private int _half = 0;//一側(cè)的卡片數(shù)
 private int _movX = 150;//X軸移動距離
 private int _movY = 50;//Y軸移動距離
 private int _movZ = 60;//Z軸移動距離
 private int count = 3;//組件數(shù)
 private List<RoleItem> _roleList = new List<RoleItem>();

 // Use this for initialization
 void Start () {
 //加載圖片
 Object[] textureList = (Object[])Resources.LoadAll("Pictures");

 int maxDepth = textureList.Length % 2 == 1 ? textureList.Length / 2 + 1 : textureList.Length / 2;//最大深度
 _half = maxDepth; 

 for (int i = 0; i < textureList.Length; i++)
 {  
  //加載角色圖片預(yù)設(shè)
  GameObject role = Instantiate(Resources.Load("Role", typeof(GameObject))) as GameObject;  
  role.transform.parent = rolesObj.transform;
  role.transform.localScale = Vector3.one;

  EventDelegate.Add(role.GetComponent<UIToggle>().onChange , RoleToggleChange);

  RoleItem item = role.GetComponent<RoleItem>();  
  item.texture.mainTexture = textureList[i] as Texture;

  //設(shè)置角色卡片排序命名
  role.name = maxDepth.ToString();
  if (i > 0)
  {
  //奇數(shù)設(shè)置為右邊,下標(biāo)為正數(shù)
  if (i % 2 == 1)
  {
   maxDepth--;
   role.name = maxDepth.ToString();
  }
  //偶數(shù)設(shè)置為左邊,下標(biāo)為負(fù)數(shù)
  else
  {
   role.name = "-" + maxDepth.ToString();
  }
  }

  SetDepthAndPosition(item,0,0);
  _roleList.Add(item);
 } 
 }


 private void SetDepthAndPosition(RoleItem role,int dir,int index)
 {
 int indexDepth = 0;
 //左右移動后,重新排序命名
 if (dir != 0)
 {
  if (index*dir > _half )
  indexDepth = -dir * (_half - 1);
  else
  indexDepth = index > -1 && index < 1 ? dir : index;
  role.name = indexDepth.ToString(); 
 } 
 else
 {
  indexDepth = int.Parse(role.name);
 }

 TweenPosition tp = role.GetComponent<TweenPosition>();
 int x = indexDepth < 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 ? true:false;
 tp.PlayForward();
 }

 /// <summary>
 /// 左邊
 /// </summary>
 public void LeftClick()
 {
 //重新排列順序
 foreach (RoleItem role in _roleList)
 {
  int index = int.Parse(role.name);
  print(index);
  SetDepthAndPosition(role,1,++index);
 } 
 }

 /// <summary>
 /// 右邊
 /// </summary>
 public void RightClick()
 {
 //重新排列順序
 foreach (RoleItem role in _roleList)
 {
  int index = int.Parse(role.name);
  SetDepthAndPosition(role,-1,--index);
 }
 }

 /// <summary>
 /// 鼠標(biāo)選中某個角色
 /// </summary>
 public void RoleToggleChange()
 { 
 if(UIToggle.current.value)
 {
  int index = int.Parse(UIToggle.current.name);
  int moveCount = _half - System.Math.Abs(index);//移動個數(shù)
  for (int i = 0; i < moveCount;i++ )
  {
  if (index > 0)
   LeftClick();
  else
   RightClick();
  }  
 }
 }

}

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • C#實現(xiàn)批量壓縮和解壓縮的示例代碼

    C#實現(xiàn)批量壓縮和解壓縮的示例代碼

    這篇文章主要為大家詳細(xì)介紹了如何利用C#實現(xiàn)批量壓縮和解壓縮的功能,文中的示例代碼講解詳細(xì),對我們學(xué)習(xí)C#有一定的幫助,感興趣的小伙伴可以跟隨小編一起了解一下
    2022-12-12
  • C#實現(xiàn)打印與打印預(yù)覽功能的思路及代碼

    C#實現(xiàn)打印與打印預(yù)覽功能的思路及代碼

    這篇文章主要介紹了C#實現(xiàn)打印與打印預(yù)覽功能的思路及代碼,有需要的朋友可以參考一下
    2013-12-12
  • Unity實現(xiàn)移動端手勢解鎖功能

    Unity實現(xiàn)移動端手勢解鎖功能

    這篇文章主要為大家詳細(xì)介紹了Unity實現(xiàn)移動端手勢解鎖功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2020-07-07
  • C#如何優(yōu)雅的結(jié)束線程

    C#如何優(yōu)雅的結(jié)束線程

    這篇文章主要介紹了C#如何優(yōu)雅的結(jié)束一個線程,本文通過示例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2021-05-05
  • C#調(diào)用sql2000存儲過程方法小結(jié)

    C#調(diào)用sql2000存儲過程方法小結(jié)

    這篇文章主要介紹了C#調(diào)用sql2000存儲過程的方法,以實例形式分別對調(diào)用帶輸入?yún)?shù)及輸出參數(shù)的存儲過程進行了詳細(xì)分析,非常具有實用價值,需要的朋友可以參考下
    2014-10-10
  • C#實現(xiàn)為一張大尺寸圖片創(chuàng)建縮略圖的方法

    C#實現(xiàn)為一張大尺寸圖片創(chuàng)建縮略圖的方法

    這篇文章主要介紹了C#實現(xiàn)為一張大尺寸圖片創(chuàng)建縮略圖的方法,涉及C#創(chuàng)建縮略圖的相關(guān)圖片操作技巧,需要的朋友可以參考下
    2015-06-06
  • 詳解ASP.NET中Identity的身份驗證代碼

    詳解ASP.NET中Identity的身份驗證代碼

    這篇文章主要介紹了ASP.NET Identity 的“多重”身份驗證代碼,以及實現(xiàn)的原理講解,需要的朋友參考一下。
    2017-12-12
  • winform調(diào)用javascript的小例子

    winform調(diào)用javascript的小例子

    winform調(diào)用javascript的小例子,需要的朋友可以參考一下
    2013-05-05
  • WPF利用TextBlock實現(xiàn)查找結(jié)果高亮顯示效果

    WPF利用TextBlock實現(xiàn)查找結(jié)果高亮顯示效果

    在應(yīng)用開發(fā)過程中,經(jīng)常遇到這樣的需求:通過關(guān)鍵字查找數(shù)據(jù),把帶有關(guān)鍵字的數(shù)據(jù)顯示出來,同時在結(jié)果中高亮顯示關(guān)鍵字,所以本文就來和大家介紹一下如何利用TextBlock實現(xiàn)查找結(jié)果高亮顯示效果吧
    2023-08-08
  • C#中屬性和成員變量的區(qū)別說明

    C#中屬性和成員變量的區(qū)別說明

    本篇文章主要是對C#中屬性和成員變量的區(qū)別進行了介紹說明。需要的朋友可以過來參考下,希望對大家有所幫助
    2014-01-01

最新評論