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 /
avatar image
0
Question by Alphius · Aug 13, 2018 at 04:17 PM · loadingreferenceassetbundles

Asset bundles and scene references

TL;DR It seems that loading a scene doesn't seem to care about AssetBundles, and just creates new instances instead of grabbing them from a loaded bundle. Is this a bug that I should report?

In order to detect the surface type of gameObjects in the scene (wood, stone, dirt etc. mostly used to play the right sound and vfx), I decided to used PhysicsMaterials. This way I can know from any collider what its surface type is. However, I'm having the following issue with AssetBundles and scenes:


  • I have my PhysicsMaterial in a bundle that we will call "bundleA".

  • I have some prefabs with some colliders with a reference to these PhysicsMaterials in a bundle that we will call "bundleB".

  • I have scenes with instances of these prefabs.


  • When I load bundleA then bundleB, everything is working perfectly, the instance of the sharedMaterial of the gameObject's colliders is the exact same one as the ones in the bundleA.

  • When I load bundleB then bundleA, it's obviously not working, that's why I am making sure when I load a bundle that I always load all of its dependant bundles first.

  • However, when I load a scene, even if I load bundleA before opening that scene, all the gameObjects in that scene have a different instance of the PhysicsMaterials, which means they don't have the same HashCode or InstanceID or anything... I really don't want to compare names because of how slow and inconsistent that could be, and I was wondering if there's any way to tell Unity to not create a new instance of these PhysicsMaterials and grab the ones of the loaded bundleA instead (which to me should be the default behaviour, maybe it's just a bug?)

Has this happened to anyone before? Does someone have a solution?

Thanks in advance!

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Alphius · Aug 14, 2018 at 03:29 PM

Figured it out: Unity does not load bundle dependencies when calling SceneManager.LoadScene, so you have to load them yourself first. If you do not do it then Unity will create new instances.


I was actually doing this, except I forgot the first scene, the one that gets loaded when the game starts. Unity does not load its dependencies either, which means you have to load an empty scene first, then load the bundles of your first scene, then load the actual scene. Annoying, but I guess it makes sense. Closing this topic.

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

92 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Async Asset Loading iOS: Slow 0 Answers

Getting exact location of asset from Addressables (How do I even go about that) 0 Answers

Assets won't load 0 Answers

Loading a specific set of sprites with addressables 0 Answers

Loading/mounting alot of assetbundles 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