playMaker

Author Topic: making a Button click go back to the scene you were just at?  (Read 2616 times)

Saputo

  • Full Member
  • ***
  • Posts: 107
making a Button click go back to the scene you were just at?
« on: April 09, 2013, 10:47:39 AM »
So I have my In Game Menu and I want the Back button to load back to the Scene it's at when, the player calls the IGM(In Game Menu) and clicks lets say Options, they go to the options, set some stuff, then click the back button and it closes and for now it loads you back at the Main Menu, but I want it to load you back to the place you were at before you clicked it. How would I go about this.

Red

  • Hero Member
  • *****
  • Posts: 563
Re: making a Button click go back to the scene you were just at?
« Reply #1 on: April 09, 2013, 01:34:49 PM »
hmm... well, there are a couple ways which i think might help this.

first could be you could set up the UI scene in such a way that you can load it without destroying the old level (i'm not sure the official jargon for this but the load-scene should have a toggle you can click to do this.) so it'll load this in a spot that's far enough away from the currently playing scene and snap the cameras to this new stuff...

Second could be that if you wanted to, you could stash the player information in the appropriate variables (vector3) as globals (one for position, one for rotation) and if you're using player prefs, you could stash all the pertinent details in the player prefs as a sort of "standby" kinda deal... so, if you have ten enemies on screen that you want to stash, you can save their details to the prefs (or globals... but that'd make that list go insanely high depending on how much you need to stash.) this might work since if you click to the UI screen it can remember what you need it to remember so that when you click back, it should be able to remember the appropriate details. this would get very hairy to set up though... so, personally i'd rather go for the first option.

I'm sure there are other ways you could do this... though i'm not sure which ones would be the best options...

as for another potential solution, maybe consider revamping your UI so that it's all contained in the UI? that way if you're using the native UI or another thing like NGUI then you can easily just turn it on and off as needed.

Saputo

  • Full Member
  • ***
  • Posts: 107
Re: making a Button click go back to the scene you were just at?
« Reply #2 on: April 09, 2013, 01:48:42 PM »
the first one does sound a bit cleaner, but I have the Options Button on the Main Menu and also on the In Game Menu, like all games do,so when u click Options and ur done setting them, it goes back to right were you left off. So I need to some how make this work,right now I'm just using Load level so while I make my new UI System.

Red

  • Hero Member
  • *****
  • Posts: 563
Re: making a Button click go back to the scene you were just at?
« Reply #3 on: April 09, 2013, 02:28:08 PM »
well, I don't want to say that having a separate scene for a UI is a bad idea (it's not... it just takes a lot of finickey work to get it done right for in-game stuff) but if i may, maybe consider making the in-game menu a separate thing from the pre-game menu?

it'd save you a lot of hassle for having to stash all the objects in the scene for sure unless you make the UI load into the scene itself in some spot where it's not going to be visible or affected by the game play.

Don't get me wrong, i'm not trying to be critical, but that is a pretty beefy thing you're asking about and i can see it getting to nightmare levels of frustration keeping all the variables and objects managed properly.

Saputo

  • Full Member
  • ***
  • Posts: 107
Re: making a Button click go back to the scene you were just at?
« Reply #4 on: April 09, 2013, 02:39:31 PM »
I could just get rid of the Options button, for the in game menu but I will still have the problem being I need it for when the Player opens the IGM and clicks Save it then shows the save game screen and then, they need to hit the back button to go back to the game that was just if I can paused, so either way I kinda need to figure this out.

Red

  • Hero Member
  • *****
  • Posts: 563
Re: making a Button click go back to the scene you were just at?
« Reply #5 on: April 09, 2013, 04:15:41 PM »
well, if you want me to describe how i'd personally approach that, i'd probably clone the menu so that there are duplicates... so, a separate scene for the menu that is external to the levels being played and an instance of the same thing in each level somewhere hidden... then when the player needs to access it, i'd simply set the time-scale to 0 (so as to stop the game in-progress) then disable the main camera and activate a secondary camera that is controlled by the menu system.

that's how i'd personally approach it... not sure if this is the most ideal way though... but it would save me having to stash all the data and then fetch it again since it's all still there, just sitting frozen at a single spot.

so, that's pretty much all i can really suggest... but, then again i'm not sure if it'd be the most efficient since if you only ever have the player on the screen and that's the only game entity that you'd have to stash, maybe the prefs/globals idea might work... still, i can see more potential errors with the stashing approach than the "instanced menu hidden somewhere far away from the main level and only activated when needed" approach.