- Home /
How to take a GameObject from A scene to B scene when the GO was instantiated?
I know use Application.LoadLevel(B);
and DontDestroyOnLoad(the GameObject);
However the gameObject is made from script when connect to the server.So I can't get the GameObject;
what gameobject, what hierachy do you have... please explain more. the more you share, the more response you get.
especially when it is made from script it should be easier to add to DontDestroyOnLoad, so explain some more.
What is making the game-object? You need a way of getting it so you could tag it or squirrel it away in a static class so all scripts can see it, but Aldwoni said - if you're creating it in a script it would be the perfect time to set it DontDestroyOnLoad(). If you don't know whether to do that then you need to store it somewhere or be able to get at it either because it was the GO for the collider you hit or some other event where you can get at the GO relating to the component triggering the script - where are you in your code when you call Application.LoadLevel()
Answer by Peter G · Jul 26, 2011 at 12:31 PM
Just make sure you have a reference to the game object when you create it.
//C# or js, whatever you want it to be.
var myGO = Instantiate() as GameObject;
DontDestroyOnLoad(myGO);
Your answer
Follow this Question
Related Questions
How do I change scenes from triggers in UNity 1 Answer
How to teleport to different scenes? 2 Answers
switching applications level... 1 Answer
how to link scenes ? 4 Answers