0
幸運の車輪を作って、賞のリストと賞のイメージのリストを持っているので、最後に賞のイメージで賞を表示したいです。私は賞品を表示することができますが、賞品イメージは表示しません。 (ディスプレイは、車輪止めスピニングアクティブパネルの上にある)、ここでどのように2つのリストの2つの要素を表示できますか?
はスクリプトです:誰でも助けることができる場合
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class SpinWheel : MonoBehaviour
{
public List<string> Premio = new List<string>();
public List<AnimationCurve> animationCurves;
public List<GameObject> ImagenPremio = new List<GameObject>();
public Text itemNumberDisplay;
private bool spinning;
private float anglePerItem;
private int randomTime;
private int itemNumber;
public GameObject RoundEndDisplay;
void Start()
{
spinning = false;
anglePerItem = 360/Premio.Count;
itemNumberDisplay.text = "";
}
void Update()
{
if (Input.GetKeyDown(KeyCode.Mouse0) && !spinning)
{
randomTime = Random.Range(1, 4);
itemNumber = Random.Range(0, Premio.Count);
float maxAngle = 360 * randomTime + (itemNumber * anglePerItem);
StartCoroutine(SpinTheWheel(5 * randomTime, maxAngle));
}
}
IEnumerator SpinTheWheel(float time, float maxAngle)
{
spinning = true;
float timer = 0.0f;
float startAngle = transform.eulerAngles.z;
maxAngle = maxAngle - startAngle;
int animationCurveNumber = Random.Range(0, animationCurves.Count);
Debug.Log("Animation Curve No. : " + animationCurveNumber);
while (timer < time)
{
//to calculate rotation
float angle = maxAngle *
animationCurves[animationCurveNumber].Evaluate(timer/time);
transform.eulerAngles = new Vector3(0.0f, 0.0f, angle + startAngle);
timer += Time.deltaTime;
yield return 0;
}
transform.eulerAngles = new Vector3(0.0f, 0.0f, maxAngle + startAngle);
spinning = false;
Debug.Log("Premio: " + Premio[itemNumber]);
if (spinning == false)
{
yield return new WaitForSeconds(1);
RoundEndDisplay.SetActive(true);
itemNumberDisplay.text = ("Premio: " + Premio[itemNumber]);
}
}
}
は、私は喜んでいるだろう!
あなたの変数 'スピニング'はスペースの無駄のようです。 'Update'は一度しか呼び出されないので、実際には何もしません。 'Update'と' SpinTheWheel'が並行して走っていたら、どうすれば役に立つのか分かります。しかし、それはまた、あなたがそれをどのように使用するかを変更する必要があります。 –
はImagenPremioのイメージ報酬のリストですか?それらはスプライトを付けられた隠されたゲームオブジェクトですか?なぜImagenPremio [itemnumber] .SetActive(true);を使用しないのですか。 – ryeMoss
私はあなたの質問を理解しているとは思わない。 'itemNumberDisplay.text;の直後に' setActive'を置いてください。 – ryeMoss