- Home /
Mobile render when click
Hey there,
i am working on a sudoku-like puzzlegame for android and my phone is getting very hot.
the screen only changes if the user touch a GUIButton, so i don't even need to render all the time. is it possible to make something like "render on click" or "doRenderNow();" ?
do you have an idea?
i also think that reducing the framerate should increase the battery lifetime. am i right?
thanks for your help!
Answer by fifthknotch · Mar 06, 2014 at 04:39 AM
I haven't ever tried anything like "render on click", but let me be the first to tell you that OnGUI is horrible about eating up processing power, ESPECIALLY on mobile devices. Before making your game update only when touching the screen, try changing your GUI buttons into gameObjects that detect touch input. From there you can move your code under Update functions or even better OnTrigger functions.
Hope this helps!
okay that is really stupid... why is gui so inefficient? -.- so i am supposed to use 3d objects to make a 2d game... awesome..
i have a field beeing build with for() and making that with gameobjects would be much more difficult...
maybe i should build a selfmade "guiSystem" wich works more efficiently... would you have an idea how i could do that without gameobjects?`
I have used triggers over my buttons on my mobile apps. They work the same way. Just have the trigger look for touch input through an if statement and put the remaining code inside the if. Unfortunately, if you have created custom GUI styles and skins, creating new game objects can become a huge hassle. But at least you know now for in the future.
Answer by Sisso · Mar 06, 2014 at 12:47 PM
It is possible, for example by using camera.clearFlags. Each time that you change stuff, you create the object, draw it and delete or disable.
Because directly control of canvas and game loop is not the main point of the engine, go on this path will not be easy. Consider to use another game engine could be better to your game.
About the gui, like @fifthknotch said currently unity3d build-in gui is terrible. Personally I am very happy with ngui, give it a try.
Reduce gameobjects generally do nothing. Never optimize before profile, generally is a lost of time and increase code complexity.