Is there anyway to display a picture without making use of a gui script? This could be used when coming close to objects, to tell you to press a button.
Thanks! ![]()
Is there anyway to display a picture without making use of a gui script? This could be used when coming close to objects, to tell you to press a button.
Thanks! ![]()
You can use GUITexture (GameObject → Create Other → GUITexture). You’ll have to enable/disable it via script for that still, though. No way around that.
I believe you can use Graphics.DrawTexture() outside of GUI code. So you could say, use a Coroutine to do something like:
IEnumerator PlayerIsClose(){
while (playerIsClose){
Graphics.DrawTexture(rect, texture2d, material);
yield;
}
}
EDIT: It’s worth mentioning that Graphics. is Unity Pro only; didn’t think about that. Not sure which version you are using, but if you aren’t using pro you will have to either use a GUITexture (which still avoids using OnGUI calls - which I’m guessing is what you are trying to avoid) or use GUI code.
Hi Everyone!! I was trying to avoid using a GUI skin, As I think that is for more permanent graphics, like health bars, and ammo, and so on… I just wanted to have a image display when close to a switch, and i found it to actually be a simple task. Using just a label, but instead of text, a image ![]()
The code is below:
function OnGUI () {
switch(IsClose)
{
case true:
GUI.Label (Rect (10, 40, textureToDisplay.width, textureToDisplay.height),
textureToDisplay);
break;
}
}
So now, whenever you are close to the door switch it displays the image which i stored in the variable “textureToDisplay”
Thank you all for your help and pointing me in the right direction! Appreciate it a lot!! ![]()