中文字幕第五页-中文字幕第页-中文字幕韩国-中文字幕最新-国产尤物二区三区在线观看-国产尤物福利视频一区二区

Unity實現跑馬燈抽獎效果

Unity 跑馬燈抽獎效果實現代碼,供大家參考,具體內容如下

倉山ssl適用于網站、小程序/APP、API接口等需要進行數據傳輸應用場景,ssl證書未來市場廣闊!成為成都創新互聯的ssl證書銷售渠道,可以享受市場價格4-6折優惠!如果有意向歡迎電話聯系或者加微信:18982081108(備注:SSL證書合作)期待與您的合作!

這邊用到插件是NGUI+Dotween,思路簡單說下:先排版,通過移動圖片蒙版來實現效果。
下面是排版和文件目錄。

Unity實現跑馬燈抽獎效果

代碼部分是通過余數去確認停的位置,boxlist通過unity拖拉加入數據,chooseBoxList直接通過余數判斷添加。
代碼量很少,稍微看下就明白了。

直接上代碼了:

using System;
using System.Collections;
using System.Collections.Generic;
using DG.Tweening;
using UnityEngine;

public class goLuckyDraw : MonoBehaviour
{
  private int index = 23;
  //index%12 來判斷停在哪個位置
 // Use this for initialization
  private UISprite prize1,prize2,prize3,prize4,prize5,prize6,prize7,prize8,prize9,prize10,prize11,prize12, prize13, prize14;
  private UISprite transparentBox;
  public List<Transform> boxList = new List<Transform>();
  public List<Transform> chooseBoxList = new List<Transform>();
  void Start () {
    prize1 = GameObject.Find("Lucky/Bg/prize1").GetComponent<UISprite>();
    prize2 = GameObject.Find("Lucky/Bg/prize2").GetComponent<UISprite>();
    prize3 = GameObject.Find("Lucky/Bg/prize3").GetComponent<UISprite>();
    prize4 = GameObject.Find("Lucky/Bg/prize4").GetComponent<UISprite>();
    prize5 = GameObject.Find("Lucky/Bg/prize5").GetComponent<UISprite>();
    prize6 = GameObject.Find("Lucky/Bg/prize6").GetComponent<UISprite>();
    prize7 = GameObject.Find("Lucky/Bg/prize7").GetComponent<UISprite>();
    prize8 = GameObject.Find("Lucky/Bg/prize8").GetComponent<UISprite>();
    prize9 = GameObject.Find("Lucky/Bg/prize9").GetComponent<UISprite>();
    prize10 = GameObject.Find("Lucky/Bg/prize10").GetComponent<UISprite>();
    prize11 = GameObject.Find("Lucky/Bg/prize11").GetComponent<UISprite>();
    prize12 = GameObject.Find("Lucky/Bg/prize12").GetComponent<UISprite>();
    prize13 = GameObject.Find("Lucky/Bg/prize13").GetComponent<UISprite>();
    prize14 = GameObject.Find("Lucky/Bg/prize14").GetComponent<UISprite>();
    transparentBox = GameObject.Find("Bg/Transparentbox").GetComponent<UISprite>();
    transparentBox.gameObject.SetActive(false);
    //獲取需要監聽的按鈕對象
    GameObject button = GameObject.Find("Lucky/Bg/start");
    //設置這個按鈕的監聽,指向本類的ButtonClick方法中。
    UIEventListener.Get(button).onClick = StartLuckyDraw;

    chooseIndex(index);

    // StartLuckyDraw();
   
  }

  IEnumerator Move( )
  {
    float time;
    
    for (int i = 0; i < boxList.Count; i++)
    {
      time = Mathf.Lerp(0.04f, 0.05f, 0.05f*i);
      Debug.Log("---time----="+time);
      transparentBox.transform.DOLocalMove(boxList[i].localPosition, time);
      yield return new WaitForSeconds(0.05f);
    }
    for (int i = 0; i < boxList.Count; i++)
    {
      time = Mathf.Lerp(0.05f, 0.065f, 0.05f * i);
      Debug.Log("---time3----=" + time);
      transparentBox.transform.DOLocalMove(boxList[i].localPosition, time);
      yield return new WaitForSeconds(0.05f);
    }
    for (int i = 0; i < boxList.Count; i++)
    {
      time = Mathf.Lerp(0.065f, 0.08f, 0.05f * i);
      Debug.Log("---time2----=" + time);
      transparentBox.transform.DOLocalMove(boxList[i].localPosition, time);
      yield return new WaitForSeconds(0.05f);
    }
    for (int i = 0; i < chooseBoxList.Count; i++)
    {
      transparentBox.transform.DOLocalMove(chooseBoxList[i].localPosition,0.1f);
      yield return new WaitForSeconds(0.1f);
    }
    yield return new WaitForSeconds(2f);
    transparentBox.gameObject.SetActive(false);
  }

  private void chooseIndex(int index)
  {
    chooseBoxList.Clear();
    for (int i = 0; i < index % 12; i++)
    {
      chooseBoxList.Add(boxList[i]);
    }
  }

  private void StartLuckyDraw(GameObject go)
  {
    transparentBox.gameObject.SetActive(true);
    StartCoroutine(Move());
  }

  void Update () {
 
 }
}

代碼很糙,大家自己完善吧!

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持創新互聯。

本文題目:Unity實現跑馬燈抽獎效果
當前網址:http://www.2m8n56k.cn/article6/pdisig.html

成都網站建設公司_創新互聯,為您提供網站設計公司標簽優化微信公眾號ChatGPT響應式網站企業網站制作

廣告

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

成都app開發公司
主站蜘蛛池模板: 国产成人精品男人的天堂网站 | 欧美最爽乱淫视频播放黑人 | 亚洲一区二区在线成人 | 免费黄色一级网站 | 日本久久精品视频 | 国产在线精品成人一区二区三区 | 免费看一级欧美激情毛片 | 99热免费在线 | 伊人成人在线 | 日本毛片在线观看 | 国产精品亚洲成在人线 | 久久久久久一级毛片免费无遮挡 | 亚洲乱强 | 免费视频精品一区二区三区 | 精品久久久久久国产91 | 色老头一级毛片 | 欧洲美女与男人做爰 | 久久性生大片免费观看性 | 亚洲欧洲一区二区三区在线 | 欧美日韩精品在线视频 | 久久久国产精品网站 | 久久三级国产 | 99久久亚洲 | 欧美精品1| 99久久九九 | 久久久久久久国产免费看 | 国产一毛片| 亚洲欧美日韩在线播放 | 一区二区三区免费在线视频 | 亚洲欧洲一区二区三区在线 | 精品色综合 | 免费人成网站在线播放 | 精品欧美日韩一区二区 | 国产高清视频在线观看 | 自拍偷拍视频在线观看 | 国产成人久久一区二区三区 | 波多野结衣在线观看高清免费资源 | 日韩a一级欧美一级 | 日韩毛片免费在线观看 | 国产孕妇孕交大片孕 | 天堂一区二区三区在线观看 |