x


Not loading an object if it have be retained from a previous scene.

Hello,

I'm retaining a gameObject called "OverControl" (It's used to keep track of all the games overall functions), using dontdestroyonload.

The problem, is when I return to the menu, when it's first instantiated... It load the one in the menu too. So I'm then stuck to having two of them.

So my guess is that I'd have a pre-loader screen that will set and instantiate everything that is needed, so that there's a screen that the player doesn't return to.

Or, create an object that instantiate the "OverControl" if it doesn't exist.

So I ask, what would be the best solution? Considering there will be a "Save" that will be deeply intertwined with the "OverControl" later on.

more ▼

asked Nov 25 '10 at 06:51 PM

Oninji gravatar image

Oninji
332 43 47 50

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

I think you've basically enumerated the two solutions that I would consider for something like this, those being:

  1. Place the object in a scene that's never returned to (such as a splash screen or intro of some sort).

  2. Write code that creates the object dynamically, and that ensures only one such object is created.

more ▼

answered Nov 25 '10 at 09:53 PM

Jesse Anders gravatar image

Jesse Anders
7.3k 7 17 48

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x5081
x3460
x437
x436
x82

asked: Nov 25 '10 at 06:51 PM

Seen: 608 times

Last Updated: Nov 25 '10 at 06:51 PM