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 AndyP-123 · Feb 05, 2018 at 03:21 AM · assetbundlescriptableobject

Using ScriptableObject with Asset Bundles

I have a ScriptableObject that needs to be referenced by several objects that just happen to be stored in different asset bundles. Currently the ScriptableObject is not explicitly bundled itself, although the objects that need it have a public reference to it. Unfortunately, this seems to result in copies of the ScriptableObject being added to each bundle, and then when the game runs, the objects referencing it have different copies of the data, which somewhat defeats the purpose of the ScriptableObject, and in my game actually results in some bugs :/

I could put the ScriptableObject in another bundle, and reference it from there, but then everything that uses it has to know its bundle name and asset name, which is rather clumsy.

Does anyone know of a way around this bundling issue? Is there a correct and incorrect way to use ScriptableObject with asset bundles?

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

Answer by AndyP-123 · Feb 05, 2018 at 08:07 AM

The official docs explain the cause and solution to my problem here: https://docs.unity3d.com/Manual/AssetBundles-Dependencies.html


Basically, if an asset that is NOT contained in an asset bundle is referenced by an object that IS contained in an asset bundle, the referenced asset will be copied to the bundle of each asset that references it. This means that if you have several assets in different bundles referencing the same asset, they will each have their own copy of the asset built into their respective bundle and not be referencing the same data.

To get around this problem, you have to add shared assets to a separate asset bundle so that the asset will be referenced instead of copied. The shared bundle must also be loaded on startup (or at least before the referencing assets are loaded). In my case, I was using ScriptableObject assets for data, so I created a bundle named "data" and loaded that at startup. Now everything seems to be working correctly.

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

79 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

Related Questions

ScriptableObject losing data in AssetBundle 2 Answers

Loading Assetbundle scriptableobject settings. I can load the Scriptableobjects and place them in a list just fine but variables that are apart of it don't load. 1 Answer

Why isn't my scriptable object storing correctly in the AssetBundle? 0 Answers

When building AssetBundles some scriptable objects get corrupted 2 Answers

Shader References seem broken for AssetBundle in HDRP Project 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