简体   繁体   中英

press back button android when change scene close the game

i have 3 scenes
scene : mainmenu , levelselect , loadlevel

when i press back button on ..
mainmenu -> game exit
levelselect -> back to mainmenu
loadlevel -> levelselect

when i press back button on transition scene the game exit
transition from mainmenu to levelselect -> game exit
transition from levelselect to loadlevel -> game exit

i don't know what happend in here.

sorry if repost

I assume when you mean "scenes" is your activities and "press back button" is your physical back button. Anyway, why dont you try to override your "physical" back button:

@Override
public void onBackPressed() {

                Intent i = new Intent(Activity.this,
                        OtherActivity.class);
                //set this flag to avoid undesired transictions between activities
                i.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
                startActivity(i);

    }

i just found the answer
this error happend because bug of unity 4.3
override function backPress will not work
thx for your time

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM