반응형
코드 작성
using UnityEngine;
using System.Collections;
public class Roulette : MonoBehaviour
{
public int[] numbers; //당첨될 것들
private int winningNumber; //당첨 번호
private bool spinning = false;
public float spinTime = 5.0f;
void Start()
{
winningNumber = -1;
}
void Update()
{
if (spinning)
{
transform.Rotate(Vector3.up, 10.0f);
}
}
IEnumerator Spin()
{
spinning = true;
yield return new WaitForSeconds(spinTime);
spinning = false;
int index = Random.Range(0, numbers.Length);
winningNumber = numbers[index];
Debug.Log("Winning Number: " + winningNumber);
}
void OnGUI()
{
if (GUI.Button(new Rect(10, 10, 100, 50), "Spin"))
{
StartCoroutine(Spin());
}
}
}
반응형