zoukankan      html  css  js  c++  java
  • Unity3d 游戏退出界面1

    功能需求:点击退出按钮,弹出“退出”UI,询问玩家是否退出游戏;

    退出按钮

    退出UI:

    publicclass GameQuit : MonoBehaviour {

    // 取消按钮

    public  GameObject   closeBt;

    // 退出UI

    public  GameObject   goUI;

    // 退出按钮

    public  GameObject   openBt;

    //确定退出游戏按钮

    public  GameObject   quitBt;

    void Start () {

    NGUIAddListener();

    }

    void NGUIAddListener(){

    if(openBt) UIEventListener.Get(openBt).onPress += openMethod;

    if(quitBt) UIEventListener.Get(quitBt).onPress += quitMethod;

    if(closeBt) UIEventListener.Get(closeBt).onPress += clooseMethod;

    }

    // /确定退出游戏

       void quitMethod(GameObject go, bool istrue) {

            if (istrue)

                return;

        Application.Quit();

        }

    //点击退出按钮,弹出退出UI

    void openMethod(GameObject go, bool istrue) {

            if (istrue)

                return;

        openCloseQuitUI(true);

        }

    //取消游戏退出,关闭弹出UI

     void clooseMethod(GameObject go, bool istrue) {

            if (istrue)

                return;

    openCloseQuitUI(false);

        }

    void openCloseQuitUI( bool isbool){

    if(goUI && goUI.active!=isbool) goUI.SetActiveRecursively(isbool);

    }

    }

  • 相关阅读:
    配置gulpfile,添加task任务
    requestAnimationFrame初探
    实现图片的预加载和懒加载
    jquery实现复制到粘贴板
    微信H5页面遇到的一些问题
    js实现日历的简单算法
    handlebars.js的运用与整理
    倒计时插件
    div 模拟<select>事件
    Emacs添加主题插件(Win系统)
  • 原文地址:https://www.cnblogs.com/kuangwu/p/3208242.html
Copyright © 2011-2022 走看看