纳金网

标题: OK Cancel 或者只有一个OK框的通用方法 [打印本页]

作者: 王者再临    时间: 2015-10-29 23:58
标题: OK Cancel 或者只有一个OK框的通用方法
OK Cancel 或者只有一个OK框的通用方法
  1. using UnityEngine;
  2. using System.Collections;
  3. using UnityEngine.UI;

  4. public class WarningPanel : MonoBehaviour
  5. {

  6.         public delegate void Callback_OK();
  7.         public Callback_OK callOK;
  8.         public delegate void Callback_Cancel();
  9.         public Callback_Cancel callCancel;

  10.         public Text txtInfo;

  11.         public Button btnOK;
  12.         public Button btnCancel;
  13.         public Button btnOneOK;

  14.         // Use this for initialization
  15.         void Start ()
  16.         {
  17.                 //txtInfo.text = "";
  18.         }
  19.        
  20.         // Update is called once per frame
  21.         void Update () {
  22.        
  23.         }

  24.         public void Show(int mode)
  25.         {
  26.                 gameObject.SetActive (true);
  27.                 SetMode (mode);
  28.         }
  29.        
  30.         public void Hide()
  31.         {
  32.                 gameObject.SetActive (false);
  33.         }

  34.         public void onBtnOK()
  35.         {
  36.                 if(callOK!=null)
  37.                         callOK();
  38.                 Main.soundMgr.Play (SoundMgr.Btn_0);

  39.         }

  40.         public void onBtnCancel()
  41.         {
  42.                 callCancel ();
  43.                 Main.soundMgr.Play (SoundMgr.Btn_0);
  44.         }

  45.         public void SetMode(int num)
  46.         {
  47.                 btnOK.gameObject.SetActive( num==2);
  48.                 btnCancel.gameObject.SetActive (num == 2);
  49.                 btnOneOK.gameObject.SetActive (num == 1);
  50.         }
  51. }
复制代码





欢迎光临 纳金网 (http://go.narkii.com/club/) Powered by Discuz! X2.5