Communicate between scenes with prefabs?
So I want to make a game logic like, I have a Main_Level, from that you can go to 4 sublevels.If you change something in the sublevel, when coming back to the Main_Level, there will be a change due to the change of sublevel. For example: From the Main_Level you going to the Level_01, triggering an object there, and you coming back after that to the Main_Level, and due to that triggering there will appear an object, that wasn't there before.
So I've tried to do the following: Created a Prefab in the Main_Level, and created a script for the trigger in the Level_01, which activating this Prefab. When you coming back to the Main_Level it will appear. And thats working in the editor, but in the build doesn't. Any ideas to make it work?
Thanks! Máté
Answer by DiegoSLTS · Oct 23, 2015 at 12:57 PM
Are you modifyng the prefab asset directly? You can't do that in a build, the assets are locked. I thought it didn't work in the editor either.
Anyway, that's not a good approach, you should save the information in a file and use that information when you need to. For example, use a text file, in the sub_level and add a line to that file with some ID when you want to acivate that object in the main level, then in the main_level always check that file, and activate the object if the ID is in there.
Oh, right. Thanks for the fast reply!
So, can you help me with an example? Like activate an object in $$anonymous$$ain_Level, with a trigger in the Sub_Level. I'm newbie in Unity..
Answer by vmworks · Oct 23, 2015 at 03:27 PM
Cool, i found a solution in that question:
http://answers.unity3d.com/questions/459049/destroy-object-in-different-scene.html
Just made an empty GameObject in Main_Level, added a script with static variables, then created an other script. In the other script I can change the static variable in the first script. And it can communicate between the scenes!
Your answer
Follow this Question
Related Questions
How can I make my melee attack hit multiple prefab enemies? 1 Answer
Managing Levels in a 3D Game 0 Answers
Should stages be separated by multiple scenes or code? 3 Answers
How to handle levels 0 Answers