Polishing Your Game Menu

確認済のバージョン: 5.4

-

難易度: 初級

In this live training session we will look at adding polish to your game menu including audio, animation and transitions using Unity's UI system.

Polishing Your Game Menu

初級 User Interface (UI)

This builds on content created in the Creating a Main Menu live training session which can be found here .


Download the original asset package used here


Get the audio used from the VR Samples package here

LoadOnEnter

Code snippet

using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;

public class LoadOnEnter : StateMachineBehaviour {

     // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) 
    {
        SceneManager.LoadScene (1);
    }
}

QuitOnEnter

Code snippet

using UnityEngine;
using System.Collections;

public class QuitOnEnter : StateMachineBehaviour {

     // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) 
    {
        Quit ();
    }

    public void Quit()
    {
        #if UNITY_EDITOR
        UnityEditor.EditorApplication.isPlaying = false;
        #else
        Application.Quit ();
        #endif
    }

}

関連するチュートリアル