I have two scenes:
A BaseScene with a GameManager object that receives two prefabs.
A Bedroom scene, with a RoomInit script that will get the prefabs references from the GameManager and instantiate them.
However, I was expecting to have the objects instantiated on the Bedroom scene rather than the BaseScene.
Why is that? Can I set which scene I want my objects instantiated?
Some code would help here... Which scene are you in? Have you loaded them additively or in single scene mode? How are you referencing the objects?
We're experiencing the same issue. Unity version: 5.3.5f1, 5.3.5p1, 5.3.5p2, 5.3.5p3, 5.3.5p4 We're loading scenes additively. Some objects (we don't have a clear repro case right now) will get instantiated in the scene we loaded as single.
Our flow is: - Load scene_a, single mode - Load scene_b, additively - Load scene_c, additively
Then we have several scripts that will, at some point, instantiate stuff. One of the scripts in scene_b (single instance, only loaded with that specific scene) will ALWAYS instantiate objects as part of scene_a.
Answer by BakewellTorte
Jan 05 at 10:26 AM
I was having the same problem...the solution is pretty straightforward.
Load your Scenes in a Coroutine and wait one from between each call. Apparently you can't set a Scene as the Active Scene in the same frame that you load it because it's not actually loaded yet.
private IEnumerator LoadLevel(int sceneIndex)
yield return new WaitForEndOfFrame();
yield return null;
yield return null;
Found the solution here. Credit to @NioFox
Answer by Lune
May 17, 2016 at 04:47 AM
having the same issue at the moment, tried with "SetActiveScene" didnt work.
Answer by Astiolo
Jan 25 at 08:08 AM
A solution I found to be easier for myself, was to set the parent of the instantiated object to something that's already in the scene that I wanted.
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a site navigation guide.
If you are a new user to Unity Answers, check out our FAQ for more information.
Make sure to check out our Knowledge Base for commonly asked Unity questions.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
Answers and Comments
8 People are following this question.
Multiple Cars not working
Distribute terrain in zones
touch to instantiate and move object ?
Instantiate prefab (button, texture) with attached script
C# Extending Script causes InvalidCastException on Instantiate