• Unity3d NGUI 按钮委托跳转场景


    _LoadLevelBt.cs 

    publicclass _LoadLevelBt : MonoBehaviour {

    public  delegatevoid ButtonLoading(string  loadingLevel);

     

    public  static  event  ButtonLoading buttonLoading;

     

    public  GameObject[]   loadLevelBtS;

    public  string[]   loadLevelNameS;

     

    void Start(){

    addListener();

    }

    void addListener(){

    foreach(GameObject go in loadLevelBtS){

    UIEventListener.Get(go).onPress+=loadList;

    }

    }

    void loadList(GameObject go,bool canwith){

    int listener=0;

    if(!canwith){

    if(listener==0){

    listener=1;

    int index=int.Parse(go.name.Split('_')[1]);

    waitButtonLoading(loadLevelNameS[index]);

    }

    }

    }

     

    public  static  void  waitButtonLoading(string  loadingLevel){

    if(buttonLoading!=null) buttonLoading(loadingLevel);

    }

    }

     

    waitButtonLoading.cs 为代理类;

    public class _ButtonLoadingList : MonoBehaviour {

    float  waitButtonLoadTime=1f;

     

    void OnEnable(){

    _LoadLevelBt.buttonLoading += buttonLoading;

    }

     

    void OnDisable(){

    _LoadLevelBt.buttonLoading -= buttonLoading;

    }

     

    public void buttonLoading(string loadingName){

     

    hideCollider();

     

    StartCoroutine(waitLoading(loadingName));

     

    }

     

    IEnumerator  waitLoading(string  loadingName){

    yieldreturnnewWaitForSeconds(waitButtonLoadTime);

    Application.LoadLevel(loadingName);

    }

    void hideCollider(){

      Collider[]   cols=Physics.OverlapSphere(Vector3.zero,1000f);

    foreach(Collider  col in cols){

    col.enabled=false;

    }

    }

    }

  • 相关阅读:
    Nginx浅谈
    MySQL 规范
    使用nginx反向代理实现隐藏端口号
    -bash: /etc/profile: line 11: syntax error near unexpected token `$'{ ''报错问题解决
    为什么禁止在 foreach 循环里进行元素的 remove/add 操作
    Java中String字符串常量池
    前端学习路径
    Linux关闭防火墙命令
    CXF实现webService服务
    Jquery Ajax 的例子。
  • 原文地址:https://www.cnblogs.com/kuangwu/p/2995862.html
Copyright © 2020-2023  润新知