- Home /
GUI Texture - from Box to Camera
Hi
I'm using this code to make an image appear when the player collides with an object
function OnTriggerEnter (Player : Collider) {
Debug.Log("Interaction");
if(Player.gameObject.tag == "Player") {
GUI.DrawTexture(new Rect(0, 0, 10, 20), noteMessage);
}
}
But, I don't actually know how to make it appear on screen - I keep getting some critical error. I know it has something to do with putting it 'on' the camera, but I am unsure how.
Answer by Graham-Dunnett · May 15, 2013 at 08:29 PM
GUI.DrawTexture
can only be used inside OnGUI()
. So in your OnTrigger
set a boolean variable to true, and then write an OnGUI()
which uses this value to decide whether to display the texture or not.
Excellent, that did the trick - thanks :-)
Simply made a bool, then used static to carry it over to the camera, have an if on that bool with the OnGUI()
Your answer
Follow this Question
Related Questions
show different textures when trigged entered thrice 2 Answers
Camera does not trigger OnTriggerEnter-event 1 Answer
Input.GetKeyDown and OnTriggerEnter problem. 2 Answers
Problem with camera in game mode. 0 Answers
Collision Checking 1 Answer