Skip to content

Instantly share code, notes, and snippets.

@tsubaki
Last active May 25, 2016 16:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsubaki/93297a683a47626301ab6284153ba6dc to your computer and use it in GitHub Desktop.
Save tsubaki/93297a683a47626301ab6284153ba6dc to your computer and use it in GitHub Desktop.
終了確認のダイアログを表示する奴
using UnityEngine;
using System.Collections;
public class ExitSample : MonoBehaviour {
/// <summary>
/// ダイアログのキャンバス
/// </summary>
[SerializeField]
Canvas canvas;
void Start()
{
canvas.enabled = false;
}
void OnApplicationQuit()
{
// ダイアログが開いていなければ終了処理はキャンセル
if (canvas.enabled == false)
Application.CancelQuit();
// ダイアログの表示
canvas.enabled = true;
}
/// <summary>
/// 終了ボタン
/// </summary>
public void OnCallExit()
{
Application.Quit();
}
/// <summary>
/// キャンセルボタン
/// </summary>
public void OnCallCancel()
{
canvas.enabled = false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment