How can I display two elements of two list?
So im making a Wheel of fortune, and have a list of prize and a list of the image of the prize, so i want to display the prize with the prize image at the end. I manage to display the prize but not the prize image. (the display is on a panel that activates when the wheel stop spinning)
here is the script:
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]);
}
}
}
I would be glad if anyone can help!
Answer by Chino_96 · Aug 25, 2017 at 02:34 PM
ImagenPremio[itemnumber].SetActive(true); I just put all in panels and then display them so no need to use 2 list and way more easy!
Your answer
Follow this Question
Related Questions
How can i disable/enable slowly the blur effect using the blur script ? 0 Answers
How can I give each instance a enum mode from another script ? 0 Answers
How can i set the camera to be automatic behind the player ? 0 Answers
How can i make the right choice of implementation of my shooting fire script ? 1 Answer
can i get help please 0 Answers