- Home /
Why would my GuiLayout area ease in but not ease out
Details. So I have a script that will ease a menu into view (slide it up from the bottom) on right-click and then ease it back out when you right-click again. Easing in works great but when I right-click again to ease it out, it stays in it's position until its counter hits 0 then it pops into position outside of view. Any help you all can provide would be GREATLY appreciated. Code snippet below:
var dialogueHidden = true;
var startEaseIn = false;
var startEaseOut = false;
var showDialogue = false;
var easeCount = 0;
var easeSpeed = 2;
function OnGUI() {
if (!startEaseIn || !startEaseOut)
{
if (dialogueHidden)
{
if (Input.GetMouseButtonDown(1)) // right-click catch
{
startEaseIn = true;
}
}
if (!dialogueHidden)
{
if (Input.GetMouseButtonDown(1)) // right-click catch
{
startEaseOut = true;
}
}
}
if (startEaseIn)
{
if (easeCount < 226)
{
easeCount+=easeSpeed;
GUILayout.BeginArea(Rect(0, (Screen.height - 10) - easeCount, Screen.width, Screen.height), dialogueBkgOpen);
GUILayout.FlexibleSpace();
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
GUI.skin = customSkinOne;
if (GUI.Button(new Rect(160, 75, 128, 128), ""))
{
//do something on button press
}
GUILayout.FlexibleSpace();
GUI.skin = customSkinTwo;
if (GUI.Button(new Rect(352, 75, 128, 128), ""))
{
//do something on button press
}
GUILayout.FlexibleSpace();
GUI.skin = customSkinThree;
if (GUI.Button(new Rect(544, 75, 128, 128), ""))
{
//do something on button press
}
GUILayout.FlexibleSpace();
GUI.skin = customSkinFour;
if (GUI.Button(new Rect(736, 75, 128, 128), ""))
{
//do something on button press
}
GUI.skin = null;
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
GUILayout.FlexibleSpace();
GUILayout.EndArea();
}
else
{
startEaseIn = false;
showDialogue = true;
dialogueHidden = false;
easeCount = 226;
}
}
if (startEaseOut)
{
if (easeCount > 0)
{
GUILayout.BeginArea(Rect(0, Screen.height - (easeCount + 10), Screen.width, Screen.height), dialogueBkgClose);
GUILayout.FlexibleSpace();
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
GUI.skin = customSkinOne;
if (GUI.Button(new Rect(160, 75, 128, 128), ""))
{
//do something on button press
}
GUILayout.FlexibleSpace();
GUI.skin = customSkinTwo;
if (GUI.Button(new Rect(352, 75, 128, 128), ""))
{
//do something on button press
}
GUILayout.FlexibleSpace();
GUI.skin = customSkinThree;
if (GUI.Button(new Rect(544, 75, 128, 128), ""))
{
//do something on button press
}
GUILayout.FlexibleSpace();
GUI.skin = customSkinFour;
if (GUI.Button(new Rect(736, 75, 128, 128), ""))
{
//do something on button press
}
GUI.skin = null;
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
GUILayout.FlexibleSpace();
GUILayout.EndArea();
easeCount-=easeSpeed;
}
else
{
startEaseOut = false;
showDialogue = false;
dialogueHidden = true;
easeCount = 0;
}
}
if(showDialogue)
{
GUILayout.BeginArea(Rect(0, Screen.height - 226, Screen.width, Screen.height), dialogueBkgClose);
GUILayout.FlexibleSpace();
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
GUI.skin = customSkinOne;
if (GUI.Button(new Rect(160, 75, 128, 128), ""))
{
//do something on button press
}
GUILayout.FlexibleSpace();
GUI.skin = customSkinTwo;
if (GUI.Button(new Rect(352, 75, 128, 128), ""))
{
//do something on button press
}
GUILayout.FlexibleSpace();
GUI.skin = customSkinThree;
if (GUI.Button(new Rect(544, 75, 128, 128), ""))
{
//do something on button press
}
GUILayout.FlexibleSpace();
GUI.skin = customSkinFour;
if (GUI.Button(new Rect(736, 75, 128, 128), ""))
{
//do something on button press
}
GUI.skin = null;
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
GUILayout.FlexibleSpace();
GUILayout.EndArea();
}
if(!showDialogue && !startEaseIn && !startEaseOut)
{
GUILayout.BeginArea(Rect(0, Screen.height - 75, Screen.width, Screen.height), dialogueBkgOpen);
GUILayout.EndArea();
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613075443im_/https://answers.unity.com/themes/thub/images/avi.jpg)