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);

}

}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM