Created
September 8, 2016 11:48
-
-
Save sakura-crowd/45bcf931788afc2674448663be681a11 to your computer and use it in GitHub Desktop.
Unity5.4でモーダルダイアログもどきを作る ref: http://qiita.com/sakura-crowd/items/626a88808c1d3717fb73
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 TrashBox : MonoBehaviour { | |
// エディタのインスペクタで、この変数にヒエラルキーにある Canvas を割り当ててください。 | |
public Canvas canvasConfirmAllHoshiDelete = null; | |
// Use this for initialization | |
void Start() { | |
// ダイアログを表示するときまで、 Canvas を無効にしておく。 | |
if (canvasConfirmAllHoshiDelete != null) | |
{ | |
canvasConfirmAllHoshiDelete.enabled = false; | |
} | |
} | |
// クリックされた | |
void OnMouseUpAsButton() | |
{ | |
confirmAllHoshiDelete(); | |
} | |
// ダイアログを表示 | |
public void confirmAllHoshiDelete() | |
{ | |
// Canvas を有効にする | |
if (canvasConfirmAllHoshiDelete != null) | |
{ | |
canvasConfirmAllHoshiDelete.enabled = true; | |
} | |
} | |
// Yes ボタンと関連づけたイベントハンドラ関数 | |
public void onButtonYes() | |
{ | |
// Canvas を無効にする。(ダイアログを閉じる) | |
canvasConfirmAllHoshiDelete.enabled = false; | |
// アイテムの削除処理(省略) | |
} | |
// No ボタンと関連づけたイベントハンドラ関数 | |
public void onButtonNo() | |
{ | |
// Canvas を無効にする。(ダイアログを閉じる) | |
canvasConfirmAllHoshiDelete.enabled = false; | |
} | |
} |
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
if (UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject()) | |
{ | |
return; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment