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 () {

}

}


Dummy.prefab


https://www.mixamo.com

'Computer Language > 유니티' 카테고리의 다른 글

Dialog() 다이아로그  (0) 2014.11.10
더미와 다이어로그  (0) 2014.11.10
파티클 1번과 2번 2번을 주로 애용  (0) 2014.07.21
ITWEEN PATH탐지. 쉐이크, 좌우이동  (0) 2014.07.01
코루틴 예제  (0) 2014.07.01

using UnityEngine;

using System.Collections;


/*

 * 1

public class Player : MonoBehaviour {

public float Speed = 1;

public GameObject FirePrefab;

// Use this for initialization

void Start () {

}

// Update is called once per frame

void Update () {

float h = Input.GetAxis("Horizontal");

float v = Input.GetAxis("Vertical");

transform.Translate(Speed * new Vector3(h, 0, v));

if(Input.GetButtonUp("Fire1")){

GameObject particle = Instantiate(FirePrefab, transform.position, Quaternion.identity) as GameObject;

float duration = particle.GetComponent<ParticleSystem>().duration;

Destroy(particle, duration);

}

}

}

*/


 //2

public class Player : MonoBehaviour {

public GameObject FireParticle;

public int Speed;

// Use this for initialization

void Start () {

}

// Update is called once per frame

void Update () {

if(Input.GetKeyDown(KeyCode.Space)){

FireParticle.SetActive(true);

float duration = FireParticle.GetComponent<ParticleSystem>().duration;

Invoke("sleep" , duration);

}

}

void sleep(){

FireParticle.SetActive(false);

}

}


 

'Computer Language > 유니티' 카테고리의 다른 글

더미와 다이어로그  (0) 2014.11.10
캐릭터,리그 ,애니메이터  (0) 2014.07.21
ITWEEN PATH탐지. 쉐이크, 좌우이동  (0) 2014.07.01
코루틴 예제  (0) 2014.07.01
하스스톤 디딤돌  (0) 2014.07.01

+ Recent posts