Effectively, I need to know how to run a mini game and then return to a scene. I know about

DontDestroyOnLoad (this);

but that works for game objects only and doesn’t do what I need - also because it carries the objects over into the next scene. In my game you play as a computer. When you hack into a computer remotely, you have to go into a sort of mini game where you must traverse the computer for data, experience and end up ‘owning’ the computer, having destroyed its security systems. My problem is that this requires being in a different scene, where the hacking 'minigame' is played out, then return. So I could just make a new scene, fine. But when I have to return to the old scene, it has to kick off from the exact point where I left to hack the computer, as if no time had past and with nothing being different. I am stuck on how to do this, because as far as I know there is no way to write a scenes data to a binary file and the read from it when loading the scene again - and persistent data was the only solution I could think of. Any help is appreciated.


How to play the scene, load a different scene, finish that minigame and then continue from where you were in the original scene


1 Answer 1


Try to put whole minigame scene into prefab(s) and load it not like a scene, but like an object(s). If minigame is lightweight enough this will be the best choice.

  • \$\begingroup\$ Except time will proceed for the real world as well as the minigame, which isn't supposed to happen. \$\endgroup\$
    – DJpotato
    Oct 9, 2015 at 8:15
  • \$\begingroup\$ This can be mitigated using Finite State Machine pattern: wiki.unity3d.com/index.php?title=Finite_State_Machine I don't know do you have any physics in main scene or any time-related calculations, but you able to pause your game in that way. Just switch to the new state while in minigame and replace Update, FixedUpdate and other periodic functions handling with the new logic that corresponds to the current state. \$\endgroup\$
    – Skyblade
    Oct 9, 2015 at 8:21
  • \$\begingroup\$ Wow I never knew that existed. How would I make a replacement for Update/FixedUpdate? WaitForSeconds only progresses with each frame so if Update never happens, wouldn't WaitForSeconds stop as well? \$\endgroup\$
    – DJpotato
    Oct 9, 2015 at 8:25
  • \$\begingroup\$ Do not replace Update or FixedUpdate, just logic inside it. It will look like Update() { currentState.Update(); } where currentState can be any state you want and thus call its own Update() method. \$\endgroup\$
    – Skyblade
    Oct 9, 2015 at 8:37
  • \$\begingroup\$ Oh, OK I misunderstood, this is a neat solution thank you \$\endgroup\$
    – DJpotato
    Oct 9, 2015 at 8:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .