- Home /
OnGUI vs GUITexture for Tablets and Phones
I read that ONGui() is not recommended for phones and tablets and the other alternative is GUITexture. But I find GUITexture (Create Other -> GUITexture) annoying and hard to control its position with the pixelInset.
My question is: Is there any other way to create HUD/UI?
I already have my UI on my ONGui() but i want to port the game over to tablets and phones.
Answer by mh4 · Sep 09, 2013 at 05:29 PM
Well I researched more about it and it seems that it wasnt as complicated as I thought. Here are some videos that helped me out:
http://www.youtube.com/watch?v=vzDra03JJhs (SUPER USEFUL FOR POSITIONING! YIPEE!) http://www.youtube.com/watch?v=z8XUM-19kdM http://www.youtube.com/watch?v=btMdGy3hBw4
One of the most retarded thing i did was not using the OnMouseEnter() function and instead coded something like:
if (self.pixelInset.Contains(Input.mousePosition))
{
self.texture = hoverTexture;
}
Which gave me a hard time! Because if you put pixelInset x and y to 0 and have transform.position to be 0.5,0.5, the above code only works if your mouse is at the bottom left.
URGH! I feel so stupid! Well im just sharing this in case anyone runs into the same problems as me in the future.
PS: Seems to me that there isnt any other way to create GUI except for GUITextures.
Answer by Triqy · Sep 09, 2013 at 05:20 PM
I find it hard to control the GUITextures using pixelInset so instead i use the XYZ cordinaties to posistion the guis on screen to were on i want them and then use the pixel inset componet on the GUITexture to fine tune the GUI textures. Check out this like if you looking for touch input..
http://answers.unity3d.com/422187/android-guitexture-touch.html
Your answer
Follow this Question
Related Questions
how to rotate GUI Textures 5 Answers
Reduce Draw call for Multiple GUI Textures with same Texture 1 Answer
Eliminate GUITexture Excess? 1 Answer