using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Flip_Script : MonoBehaviour
{
public GameObject Flip_Animation;
public Button flip_button;
public GameObject heads;
public GameObject tails;
int rand;
// Start is called before the first frame update
void Start()
{
Flip_Animation.SetActive(false);
flip_button.interactable = true;
}
IEnumerator Flip()
{
yield return new WaitForSeconds(4);
rand = Random.Range(1, 40);
Debug.Log(rand);
if (rand % 2 == 0)
{
heads.SetActive(true);
}
else
{
tails.SetActive(true);
}
}
public void Start_Animation()
{
Flip_Animation.SetActive(true);
flip_button.interactable = false;
heads.SetActive(false);
tails.SetActive(false);
StartCoroutine(Stop_Animation());
StartCoroutine(Flip());
}
IEnumerator Stop_Animation()
{
yield return new WaitForSeconds(4);
Flip_Animation.SetActive(false);
flip_button.interactable = true;
}
}
0 Comments: