Unity 주마등 추첨 효과 실현
여기 서 플러그 인 을 사용 하 는 것 은 NGUI+Dotween 입 니 다.생각 은 간단하게 말 하면 먼저 레이아웃 을 하고 모 바 일 사진 을 통 해 효 과 를 실현 합 니 다.
다음은 조판 과 파일 디 렉 터 리 입 니 다.
코드 부분 은 잔 수 를 통 해 멈 춘 위 치 를 확인 하고 box list 는 유 니 티 드래그 를 통 해 데 이 터 를 추가 하 며 chooseBox List 는 잔 수 를 통 해 직접 판단 하여 추가 합 니 다.
코드 양 이 적어 서 조금 만 보면 알 수 있 습 니 다.
코드 가 바로 올 라 갑 니 다:
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 () {
}
}
코드 가 매우 거 칠 니 모두 스스로 보완 하 세 요!이상 이 바로 본 고의 모든 내용 입 니 다.여러분 의 학습 에 도움 이 되 고 저 희 를 많이 응원 해 주 셨 으 면 좋 겠 습 니 다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
photonnetwork.instantiate에서 gamepobject 유형을 생성 한 다음 상태 및 값을 참조하는 방법주로 마지막 기사에서 일어난 일의 수정입니다. 지난번↓ 그럼 주제입니다. (타이틀이 정리되어 없어서 죄송합니다) 우선 전회의 Illegal view ID:0입니다만 photonnetwork.instantiate를 사...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.