Time delay trigger for Unity3d

When player enters a collision area for a few seconds, a warning popup will appear. We create a timer called elapsedTime, using OnTriggerStay to start timer and OntriggerExit to reset the timer.

using UnityEngine;
using System.Collections;

public class TimeDelayTrigger : MonoBehaviour {

    public float elapsedTime = 0f;
    bool ToggleGUI = false;
    bool isCreated = false;

    void OnTriggerStay(Collider other){
        if (other.gameObject.CompareTag ("Player"))
        {
            elapsedTime += Time.deltaTime;
            Debug.Log("Started" + elapsedTime);
            if(elapsedTime >= 5.0f){
                ToggleGUI = true;
            }
        }
    }

    void OnTriggerExit(Collider other){
        elapsedTime = 0f;
    }

    void OnGUI(){
        if (ToggleGUI == true) {
            if(!isCreated){
                GameObject msg = (GameObject)Instantiate(Resources.Load("PopupMsg"));
                msg.transform.SetParent(this.transform);
                isCreated = true;
            }
        }
    }

}