Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
1
Question by vmworks · Oct 23, 2015 at 12:32 PM · prefabstriggerssceneslevelsbetween

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é

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
1

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.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image vmworks · Oct 23, 2015 at 02:02 PM 0
Share

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..

avatar image
0

Answer by Crixu · Oct 23, 2015 at 02:27 PM

Use `void Awake() { DontDestroyOnLoad(transform.gameObject); } `

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

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!

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

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

Could someone help me with scripting a Trigger that when the player enters and then presses the E Key a new level is loaded. My script is JS at the moment. 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges