- Home /
GUI_TEXTURE PROBLEM!
Hi everyone!
so i have a problem with my gui_textures when i select a png file and change it to a gui_texture i can't see it in both textures or game, so the cordinatees are right i checked them a hundred time. maybe it's the options i don't know!
please help me!
Answer by denewbie · Nov 06, 2010 at 04:37 PM
I'm not too sure how you changed it into a gui texture but here's some basic code you can use to attach your texture in the middle of the screen. Just paste it on your script and attach it to any component.
Note: Its in C#
public Texture2D myImage; public imageWidth = 200; public imageHeight = 200;
void OnGUI() { GUI.DrawTexture(new Rect( (Screen.width - imageWidth) 0.5f, Screen.height - (Screen.height - imageHeight) 0.5, imageWidth, imageHeight), myImage);
}
Answer by Snakeprogrammer · Nov 06, 2010 at 07:11 PM
Men thats complitly what i want! thanks!
*edit: but what do i need to set in the place of myimage, i made a gui_texture named GUI_lives but if i set that as image, he give me an error, please help me!
The GUI in unity is a 2D layer. Its usually advisable to have only one layer per scene otherwise dealing with the over lapping can become quite a pain. What you need is a 2D texture. This can be a jpg, png. psd or what ever stardard formats you usually have. You don't really need a GUI texture.
Your answer
Follow this Question
Related Questions
Get GUITexture to follow ScreenPointToRay ray cast 1 Answer
Toggle GUITexture V.2 1 Answer
GUITexture HitTest not registering 0 Answers