Last active
May 25, 2016 16:54
-
-
Save tsubaki/93297a683a47626301ab6284153ba6dc to your computer and use it in GitHub Desktop.
終了確認のダイアログを表示する奴
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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