Hi all, been scratching my head over this as I don’t know what I’m missing or doing wrong.
I’m trying to create a menu system when different boxes can be expanded to different levels. I’d like this to be a smooth sliding menu each time a box is expanded. Below is the code I have tried, and the position of the group of buttons, just jumps to the end location, and does not slide in the way I want/expected.
@script ExecuteInEditMode()
var title : Texture2D;
var titleBox : Texture2D;
var buttonImage : Texture2D;
var box1 : Texture2D;
var box2 : Texture2D;
var box3 : Texture2D;
var box4 : Texture2D;
var box5 : Texture2D;
var box6 : Texture2D;
var box7 : Texture2D;
var box8 : Texture2D;
var box9 : Texture2D;
var box10 : Texture2D;
var section1Min : int;
var section1Max : int;
var section1Position : int;
function Start (){
section1Min = -175;
section1Max = 75;
section1Position = -175;
}
function OnGUI () {
GUI.BeginGroup (Rect (20,20,100,325));
GUI.Box (Rect (0,0,100,375), titleBox, "");
GUI.BeginGroup (Rect (0,section1Position, 100, 250));
GUI.Box (Rect (0,0,50,50), box1, "");
GUI.Box (Rect (50,0,50,50), box2, "");
GUI.Box (Rect (0,50,50,50), box3, "");
GUI.Box (Rect (50,50,50,50), box4, "");
GUI.Box (Rect (0,100,50,50), box5, "");
GUI.Box (Rect (50,100,50,50), box6, "");
GUI.Box (Rect (0,150,50,50), box7, "");
GUI.Box (Rect (50,150,50,50), box8, "");
GUI.Box (Rect (0,200,50,50), box9, "");
GUI.Box (Rect (50,200,50,50), box10, "");
GUI.EndGroup();
GUI.Box (Rect (0,0,100,375), title, "");
if (GUI.Button (Rect (0,50,100,25), buttonImage, "")) {
section1Position = Mathf.Lerp(section1Min, section1Max, Time.time);
}
GUI.EndGroup();
}
If anybody can help at all, I’d be extremely grateful.
regards.
Mnollock