this is what i got so far
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Hint : MonoBehaviour
{
public GameObject TextObj;
float TmStart;
public float TmLen = 5f;
// Use this for initialization
void Start()
{
TmStart = Time.time;
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.Escape))
{
TextObj.SetActive(false).TmLen;
}
}
}
Hi, Do you want to make it reappear after 5 seconds or if you press the space bar?
Anyway you can try this:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Hint : MonoBehaviour {
public GameObject TextObj;
float TmStart;
public float TmLen = 5f;
// Use this for initialization
void Start()
{
TmStart = Time.time;
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown("space") && TextObj.activeSelf == true)
{
TextObj.SetActive(false);
StartCoroutine(Hide(TmLen));
}
}
IEnumerator Hide(float TmLen)
{
yield return new WaitForSeconds(TmLen);
TextObj.SetActive(true);
}
}
sorry didn’t make it clear
when you press the spacebar it deactivates the image for 5 seconds
@MT369MT
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Hint : MonoBehaviour {
// if there is a typing error Sorry I didnt write this in VS and if there is a problem with the script add a coment
public GameObject TextObj;
float TmStart;
public float TmLen = 5f;
private Renderer rend;
// Use this for initialization
void Start()
{
TmStart = Time.time;
rend = TextObj.GetComponent<Renderer>();
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown("space") && rend.enabled== true)
{
StartCoroutine(Hide(TmLen));
}
}
IEnumerator Hide(float TmLen)
{
rend.enabled = false;
yield return new WaitForSeconds(TmLen);
rend.enabled = true;`
}
}