- Home /
GUI buttons or 3D Objects as GUI?
Hello,
I've been creating a scrolling game for mobile where the axes of scrolling changes between x and z depending on the player's whereabouts. Until now, I've been using triggers to change the scrolling direction, which works great, but I want to allow for more control over changing between the scrolling direction with some kind of a GUI.
I have not worked with the GUI thus far. My idea is to have an arrow appear and disappear while the player is on a trigger. I was originally thinking of just using a 3D arrow with a box collider and sending a raycast from the camera based on the touch position ( or not using a collider (for performance) and just detecting when the touch position is in line with the object ) since I'm already using this approach for interacting with game objects in my scene.
Is this a good idea?? Or should I use the GUI system instead? I don't mind creating a custom texture for use with the GUI system if this will in some way be better for performance.. Is there a reason why to use the GUI system instead of using my approach?
Thanks in advance!!
Answer by Triqy · Feb 05, 2014 at 06:00 AM
you don't have to use the GUI system that unity provides.. here is some custom GUI button Code that I put up awhile back...
http://answers.unity3d.com/questions/422187/android-guitexture-touch.html
Just slap this in a Java Script and slap that on a Custom GUI you created and you have a button for mobile games.
Thanks, but I know that I don't have to use the unity GUI system. I was wondering if a GUI system (unity's/custom) is a better idea, performance wise, than using my alternative...
What is the overhead of GUItextures as buttons??
For a 3D object, there would be the overhead of rendering the geometry and the texture that it has, along with a way for detecting the touch ( collider or checking the touch position against the object position ) which would include calculations such as what raycasting executes or cameratoworldpoint. I'm sure that the 3D object route would include much more processing because it seems to me that a GUITexeture is simply just a texture with no geometry in screen space which excludes the 3D environment calculations. Am I correct?
I want to point out that with your code, there is no need to check every frame if the ShowGUI is true. Unless you want to have it shown at all times. Send an event out when you want to show/hide the GUI and then the GUITexture script can start a coroutine with a while loop that detects if it is suppose to show or hide the texture. Sorry, I try keeping things out of Update if not completely necessary because it is running once per frame.
Your answer
Follow this Question
Related Questions
How expensive are legacy GUI Matrix changes / RotateAroundPivot performance wise? 0 Answers
Filling image without compromises 0 Answers
GUI alternatives ? 1 Answer
GUI Menu Major Performance Issues 1 Answer
iOS performance: GUItext? want to use text string, but how to instantiate and edit it runtime? 0 Answers