I have made a very simple script to overlay a camera texture I made to give my game a found-footage style. However, I have a little “REC” icon in the corner of the overlay. I made an overlay with the recording sign in the top right, then another overlay, which is the same, but does not have the recording sign. I want these two textures to swap every two seconds, to give the impression of a blinking REC sign. I had a go at making a script for this but cannot find a good way to do it. The script is a little unfinished as I’m making this at quarter to 12 but I know that the way I am going about this is incorrect)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Overlay : MonoBehaviour
{
public Texture overlay;
public Texture overlayWithRec;
private bool isRecOn = true;
void Start ()
{
isRecOn = true;
}
void OnGUI()
{
if (GUI.DrawTexture (new Rect (0, 0, Screen.width, Screen.height), overlay))
{
StartCoroutine (Blink ());
}
}
IEnumerator Blink()
{
isRecOn = !isRecOn;
if (isRecOn == false)
{
overlay.enabled = true;
overlayWithRec.enabled = false;
}
}
}