Hi all. I have made a script so when the player does a mouse click a UI image and text pops up. I have attached this script to 100 gameobjects (a different image for each one, the same text for all). What I want to do know is to destroy-disable the UI after viewing the UI once. So if I click on gameobject 1, the UI image and text appears but if I want to view this twice then nothing happens. I used destroy function but it destroys all UI images and texts and if I click on game object 1 then gameobject 2-100 do not seem to have anything. Any help?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class RandomIndi : MonoBehaviour {
public GameObject textprefab;
public GameObject imageprefab;
IEnumerator OnMouseDown()
{
textprefab.SetActive (true);
imageprefab.SetActive (true);
Time.timeScale = 0.0f;
yield return new WaitForSecondsRealtime(3.5f);
Destroy (textprefab);
Destroy (imageprefab);
/*textprefab.SetActive (false);
imageprefab.SetActive (false);*/
Time.timeScale = 1.0f;
}
}