Hello,
I have been experimenting with different codes and I wanted to make an onGUI dropdown menu that can spread/fold smoothly based on deltaTime.
But the code doesn’t seem to work. It did occur to me that onGUI is updated every frame so the idea of using deltaTime may not be valid. I am very new to scripting. How can I make this work? I would like to keep using onGUI if possible.
if (GUI.Button(new Rect(Screen.width - (Screen.width / 8), Screen.height / 40, Screen.width / 10, Screen.height / 10), "Menu"))
{
if (show == false)
show = true;
else
show = false;
}
if (show)
{
Vector2 scale = scrollViewVector;
scale.y = Mathf.Lerp(scale.y, show ? 1 : 0, Time.deltaTime * 12);
scrollViewVector = scale;
scrollViewVector = GUI.BeginScrollView(new Rect(Screen.width - (Screen.width / 8), Screen.height / 8, Screen.width / 10, (Screen.height / 10 + 25) * list.Length), scrollViewVector, new Rect(Screen.width - (Screen.width / 8), Screen.height / 40, Screen.width / 10, Mathf.Max(Screen.height / 7, (Screen.height / 10 + 25) * list.Length)));
GUI.Box(new Rect(Screen.width - (Screen.width / 8), Screen.height / 40, Screen.width / 10, Mathf.Max((Screen.height / 10 + 25) * list.Length)), "");
for (int index = 0; index < list.Length; index++)
{
if (GUI.Button(new Rect(Screen.width - (Screen.width / 8), (Screen.height / 40 + (Screen.height / 9 * index + 15)), Screen.width / 10, Screen.height / 10), ""))
{
show = false;
indexNumber = index;
}
GUI.Label(new Rect(Screen.width - (Screen.width / 8) + 10, (Screen.height / 40 + (Screen.height / 9 * index + 15)), Screen.width / 10, Screen.height / 10), list[index], DropDownMenuFont);
}
GUI.EndScrollView();
}
}