bl双性强迫侵犯h_国产在线观看人成激情视频_蜜芽188_被诱拐的少孩全彩啪啪漫画

Unity實現3D循環滾動效果的方法-創新互聯

這篇文章主要介紹Unity實現3D循環滾動效果的方法,文中介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們一定要看完!

成都創新互聯致力于互聯網網站建設與網站營銷,提供網站制作、成都網站建設、網站開發、seo優化、網站排名、互聯網營銷、微信小程序、公眾號商城、等建站開發,成都創新互聯網站建設策劃專家,為不同類型的客戶提供良好的互聯網應用定制解決方案,幫助客戶在新的全球化互聯網環境中保持優勢。

具體內容如下

Unity實現3D循環滾動效果的方法

然后通過SetDepthAndPosition這個方法,實現圖片的空間空間展開

Unity實現3D循環滾動效果的方法

Unity實現3D循環滾動效果的方法

Z軸和Y軸,系數是一樣的

經過上面設置,空間就擺開了

Unity實現3D循環滾動效果的方法

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<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++)
  {   
   //加載角色圖片預設
   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;

   //設置角色卡片排序命名
   role.name = maxDepth.ToString();
   if (i > 0)
   {
    //奇數設置為右邊,下標為正數
    if (i % 2 == 1)
    {
     maxDepth--;
     role.name = maxDepth.ToString();
    }
    //偶數設置為左邊,下標為負數
    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>
 /// 鼠標選中某個角色
 /// </summary>
 public void RoleToggleChange()
 { 
  if(UIToggle.current.value)
  {
   int index = int.Parse(UIToggle.current.name);
   int moveCount = _half - System.Math.Abs(index);//移動個數
   for (int i = 0; i < moveCount;i++ )
   {
    if (index > 0)
     LeftClick();
    else
     RightClick();
   }   
  }
 }

}

以上是“Unity實現3D循環滾動效果的方法”這篇文章的所有內容,感謝各位的閱讀!希望分享的內容對大家有幫助,更多相關知識,歡迎關注創新互聯成都網站設計公司行業資訊頻道!

另外有需要云服務器可以了解下創新互聯scvps.cn,海內外云服務器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務器、裸金屬服務器、高防服務器、香港服務器、美國服務器、虛擬主機、免備案服務器”等云主機租用服務以及企業上云的綜合解決方案,具有“安全穩定、簡單易用、服務可用性高、性價比高”等特點與優勢,專為企業上云打造定制,能夠滿足用戶豐富、多元化的應用場景需求。

文章題目:Unity實現3D循環滾動效果的方法-創新互聯
路徑分享:http://vcdvsql.cn/article34/isipe.html

成都網站建設公司_創新互聯,為您提供Google、App設計定制開發、外貿網站建設、網頁設計公司、電子商務

廣告

聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯

成都定制網站建設