- Home /
How can I make a GUI element move independently of the frame rate?
My Gui is a group which updates all the time from OnGui:
GUI.BeginGroup (new Rect (current_pos_x,current_pos_y, smartTabBackgroundImage.width, smartTabBackgroundImage.height));
When I move the group I have tried multiplying the current_pos_x by Time.deltaTime in the update loop but this doesnt seem to do anything.
EG..set the speed dep on FPS in the main Update() loop:
tabSpeed=Time.deltaTime*10;
& now move it...(This is called from OnGui())
while(current_pos_x<=tabShownPos_x)
{
current_pos_x+=tabSpeed;
yield;
}
Anyone any ideas?
Answer by DannyB · Oct 22, 2012 at 09:27 PM
Why not
if( current_pos_x<=tabShownPos_x )
current_pos_x += 10 * Time.deltaTime;
inside the OnGUI(), and kill the need for that coroutine?
Because OnGUI can run multiple times per frame. You generally don't want to try doing movement inside OnGUI.
Your answer
Follow this Question
Related Questions
Is there a way to speed up the game more than 100 times? 1 Answer
Standalone builds run very fast on some computers? 3 Answers
Time.deltaTime does not change despite frame rate drops.? 1 Answer
How to measure time independently on frame rate? 2 Answers
Time Manager Class Implementation Like Coroutine in Unity 1 Answer