Using Unity New GUI system, Will first need to create a GUI element using Prefab and save under Resources Folder. Then upon collision trigger, instantiate the GUI prefab and display onGUI
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class PlayerContact : MonoBehaviour {
bool ToggleGUI = false;
bool isCreated = false;
// Use this for initialization
void Start () {
//Resources.Load ("PopupMsg");
}
// Update is called once per frame
void Update () {
}
void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag ("Player"))
{
//Debug.Log ("Detected");
ToggleGUI = true;
}
}
void OnGUI(){
if (ToggleGUI == true) {
if(!isCreated){
GameObject msg = (GameObject)Instantiate(Resources.Load("PopupMsg"));
isCreated = true;
}
}
}
}