I’m trying to implement a UI that has a sidebar with various buttons in a vertical GUILayout format. When a user clicks a button I would like to have a box with some simple content more or less expand outwards and away from the button into the center of the screen (starting small like the button and growing larger as it moves to the center of the screen). Have been scratching my head all day between Lerps and Berps and Expands…
Thank you for your help.
void OnGUI()
{
Rect growingBox = new Rect(150, 30, 30, 30);
....
GUILayout.BeginVertical(GUI.skin.GetStyle( "Button" ), GUILayout.Width (150));
GUILayout.Label ("Hello");
if (GUILayout.Button("Add Item"))
{
displayBox = true;
}
if (displayBox == true)
{
GUILayout.BeginArea(growingBox);
// I would like to make the box below Lerp out into the screen
GUILayout.Box("I'm a box");
// Lerp Here
GUILayout.EndArea();
}
GUILayout.Label ("etc....");
GUILayout.Label ("etc...");
GUILayout.EndVertical ();
if (GUILayout.Button("Cancel"))
{
displaySearch = false;
}
if (GUILayout.Button("Log In"))
{
}
...
}
The GUI code has to be in the OnGUI function, but you can set a boolean flag to start the animation in an OnMouseEnter and clear it again with the corresponding OnMouseExit.
@ fis: it is bad forum etiquette to post your entirely separate question in this thread. This is a thread about lerping (linear interpolating) a gui box, adding yoru questions about mouse events is not the way to go:
If we do answer your question it’s now hidden/buried under a topic heading that doesn’t match.
If you really want help it’s now buried under a topic heading that doesn’t bring the right eyeballs.
In the future, if you have a case like this (where you have a totally new question not related closely to the original post/topic) then please post a new thread of your own. So, do that now and we can lend a hand there, thanks!
@anon_85768832 : why it is not possible to call AnimateBox () method directly to OnGUI() method,Why we need to call this in Update() method,as far as i know that both the Update() and OnGUI() running on per tick or frame rate,and yes GUI is for drawing things and GUI is also faster than Update too,but don’t understand the reason that why we are not able to call method directly to OnGUI,we need to take bool variable all the time for specific work.Is there any other better way to do that.kindly help me .