public void OnButtonCharacterShow(){
print ("show");
DialogMgr.ShowDialog(CharacterSelectPrefab, OnCharacterSelectOk, OnCharacterSelectCancel, "Character Select", "Buy ??");
}
void OnCharacterSelectOk(){
print ("Select ok");
}
void OnCharacterSelectCancel(){
print ("Select Cancel");
}
using UnityEngine;
using System.Collections;
public class DialogMgr : MonoBehaviour{
static GameObject DialogPrefab;
static GameObject DialogParent;
static GameObject DialogPurchasePrefab;
static GameObject DialogPurchaseParent;
static string title = "Game Purchase";
static string message = "";
//static GameObject AddressDialogPrefab;
//static GameObject AddressDialogParent;
public static void ShowDialog(GameObject prefab, Dialog.OnButtonEvent okFunction, Dialog.OnButtonEvent cancelFunction,
string title, string message){
if(null == DialogParent){
UICamera cam = GameObject.FindObjectOfType<UICamera>();
DialogParent = cam.gameObject;
}
GameObject obj = null;
if (prefab == null) {
Debug.LogError("prefab is null");
return;
}
else {
obj = NGUITools.AddChild(DialogParent, prefab);
obj.transform.position = new Vector3(0.0f, 0.0f, -1.5f);
}
Dialog dlg = obj.GetComponent<Dialog>();
dlg.Title.text = title;
dlg.Message.text = message;
dlg.eventButtonOk += okFunction;
dlg.eventButtonCancel += cancelFunction;
NGUITools.AdjustDepth(obj, 100);
}
/*
public static void ShowAddressDialog( Dialog.OnButtonEvent okFunction, Dialog.OnButtonEvent cancelFunction){
if(null == AddressDialogParent){
UICamera cam = GameObject.FindObjectOfType<UICamera>();
AddressDialogParent = cam.gameObject;
}
if(null == AddressDialogPrefab){
DialogPrefab = Resources.Load("Prefabs/AddressBody") as GameObject;
}
GameObject obj = NGUITools.AddChild(AddressDialogParent, AddressDialogPrefab);
Dialog dlg = obj.GetComponent<Dialog>();
//dlg.Title.text = title;
//dlg.Message.text = message;
dlg.eventButtonOk += okFunction;
dlg.eventButtonCancel += cancelFunction;
NGUITools.AdjustDepth(obj, 100);
}
*/
public static void ShowPurchaseDialog(Dialog.OnButtonEvent okFunction, Dialog.OnButtonEvent cancelFunction){
if(null == DialogPurchaseParent){
UICamera cam = GameObject.FindObjectOfType<UICamera>();
DialogPurchaseParent = cam.gameObject;
}
if(null == DialogPurchasePrefab){
DialogPurchasePrefab = Resources.Load("Prefabs/Player_BackGround") as GameObject;
}
GameObject obj1 = NGUITools.AddChild(DialogPurchaseParent, DialogPurchasePrefab);
Dialog dlgPurchase = obj1.GetComponent<Dialog>();
dlgPurchase.Title.text = title;
dlgPurchase.Message.text = message;
dlgPurchase.eventButtonOk += okFunction;
dlgPurchase.eventButtonCancel += cancelFunction;
NGUITools.AdjustDepth(obj1, 300);
}
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
}
'Computer Language > 유니티' 카테고리의 다른 글
사인과 코사인 응용 방안 (0) | 2014.11.12 |
---|---|
Dialog() 다이아로그 (0) | 2014.11.10 |
캐릭터,리그 ,애니메이터 (0) | 2014.07.21 |
파티클 1번과 2번 2번을 주로 애용 (0) | 2014.07.21 |
ITWEEN PATH탐지. 쉐이크, 좌우이동 (0) | 2014.07.01 |