can you help me about this code…i want to have a button permanent next and preview…a slideshow…
public class HorizontalTransitionGUI : MonoBehaviour
{
//A 4x4 Matrix
private Matrix4x4 trsMatrix;
//A three dimension vector that will translate GUI coordinate system
private Vector3 positionVec;
//Two booleans to determine which of the GUI buttons have been pressed
private bool next = false;
private bool back = false;
// Use this for initialization
void Start()
{
//Initialize the matrix
trsMatrix = Matrix4x4.identity;
//Initialize the Vector
positionVec = Vector3.zero;
}
// Update is called once per frame
void Update()
{
//If the ‘next’ boolean is true
if(next)
{
//Interpolate the current vector x component until it has the same as value the screen width
positionVec.x = Mathf.SmoothStep(positionVec.x, Screen.width,Time.deltaTime10);
/Make ‘trsMatrix’ a matrix that translates, rotates and scales the GUI.
The position is set to positionVec, the Quaternion is set to identity
and the scale is set to one./
trsMatrix.SetTRS(positionVec , Quaternion.identity, Vector3.one);
}
else if(back) //If ‘back is true’
{
//Interpolate the current vector x component until it reaches zero
positionVec.x = Mathf.SmoothStep(positionVec.x, 0,Time.deltaTime10);
//Make ‘trsMatrix’ a matrix that translates, rotates and scales the GUI.
trsMatrix.SetTRS(positionVec , Quaternion.identity, Vector3.one);
}
}
void OnGUI()
{
//The GUI matrix must changed to the trsMatrix
GUI.matrix = trsMatrix;
//If the button labeled ‘Next’ is pressed
if(GUI.Button(new Rect(Screen.width - 400, 315, 100, 30),“Next”))
{
next = true;
back = false;
}
//The TextArea that appears on the first screen.
GUI.TextArea(new Rect(300,200,Screen.width-600,100), “Click on the ‘Next’ button to change the Text Area.”);
//If the button labeled ‘Back’ is pressed
if(GUI.Button(new Rect(-Screen.width + 300, 315, 100, 30),“Back”))
{
next = false;
back = true;
}
//The TextArea that appears on the second screen
GUI.TextArea(new Rect(-Screen.width + 300,200,Screen.width-600,100), “Click on the ‘Back’ button to return to the previous Text Area.”);
//To reset to GUI matrix, just make it equal to a 4x4 identity matrix
GUI.matrix = Matrix4x4.identity;
}
}