- Home /
How to Display Map
I was trying to figure out a script that would allow me to display a map image on the screen when I press "m" and then it would go away. I was trying to get the image to be a map of my terrain with a picture I made of it in Photoshop. I have the picture but how do I make it come up on the screen when I press "m"? I am writing it in Javascript.
Answer by shigidaMark · Mar 17, 2013 at 03:29 AM
[JavaScript] Attach a script to your camera. Add the variable:
var mapKeyDown : boolean = false;
In your camera's Update function:
if(Input.GetKeyDown("k")){
if(mapKeyDown)
mapKeyDown = false;
else
mapKeyDown = true;
}
Then in your camera's OnGUI function:
if(mapKeyDown){
GUI.DrawTexture();
//see scripting reference for what
//attributes to use for this function
}
https://docs.unity3d.com/Documentation/ScriptReference/GUI.DrawTexture.html
To add on @shigidamark's answer, if you want it to look like a FPS-style map quick-peek, you can modify the map$$anonymous$$eyDown
using:
if(Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.$$anonymous$$)){
map$$anonymous$$eyDown = true;
}
if(Input.Get$$anonymous$$eyUp($$anonymous$$eyCode.$$anonymous$$)) {
map$$anonymous$$eyDown = false;
}