Beispiel #1
0
    //Switch to the screen given a reference to the GameObject
    private void loadScreen(GameObject screen)
    {
        //Update the previous and current screens
        previousScreen = currentScreen;
        currentScreen  = screen;

        //Set the scale of the new menu to 0 for when it is loaded
        currentScreen.transform.localScale = new Vector3(0, 0, 0);
        //Disable collisions in the screen to be closed
        disableCollisions(previousScreen);
        //Update the loading state to close the old screen
        UILoadingState = loadingState.Closing;
    }
Beispiel #2
0
 //Play the animation to open a screen
 private void openScreen()
 {
     //If the new menu is more than one frame away from full size, increase the scale
     if (currentScreen.transform.localScale.x + scalePerFrame <= 1)
     {
         float newScale = currentScreen.transform.localScale.x + scalePerFrame;
         currentScreen.transform.localScale = new Vector3(newScale, newScale, newScale);
     }
     //Set the scale of the new menu to full and update the loading state
     else
     {
         currentScreen.transform.localScale = new Vector3(1, 1, 1);
         UILoadingState = loadingState.None;
         enableCollisions(currentScreen);
         firstFrameOfScreen = true;
     }
 }
Beispiel #3
0
 //Play the animation to close a screen
 private void closeScreen()
 {
     //If the old menu is more than one frame away from having a negative scale, decrese the scale
     if (previousScreen.transform.localScale.x - scalePerFrame >= 0)
     {
         float newScale = previousScreen.transform.localScale.x - scalePerFrame;
         previousScreen.transform.localScale = new Vector3(newScale, newScale, newScale);
     }
     //If the old menu is completely closed, update the loading state and visibility of the screens
     else
     {
         UILoadingState = loadingState.Opening;
         previousScreen.SetActive(false);
         currentScreen.SetActive(true);
         //Disable collisions in the screeen to be opened
         disableCollisions(currentScreen);
     }
 }