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 G-Reusch · Aug 03, 2017 at 11:03 PM · prefabassetbundle

Asset Bundles and Scripts

I have a question about scripts as they pertain to asset bundles. Obviously I can't just put a script in the asset bundle and load it since it wouldn't be compiled (can make a dll but that doesn't help in this case). However, what if I just put the script as a component on a prefab in my asset bundle, but left the script in the project to be compiled?

Would that prefab work when I load it in from the asset bundle? Would the values I set in editor for the prefab be preserved? The goal here is to be able to customize the script values of the prefabs we're loading from asset bundles, without doing "AddComponent" and manually setting the properties for each and every object loaded in from the bundle at runtime.

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
2
Best Answer

Answer by Bunny83 · Aug 04, 2017 at 01:27 AM

Yes that is possible and the intended use. As you said all your scripts are actually compiled into a single assembly (well actually a few but that's just for different compilation groups and not relevant here). Actual assets are nothing but serialized data. This includes pure data assets like meshes, textures, audioclips, ... but also any serialized class instances. A serialized gameobject hierarchy can be stored in two different ways. Either as part of a scene file, or as standalone prefab. In both cases the actual data will be stored inside the scene / prefab file.

Of course to load a serialized gameobject all classes of all components has to exist in the current AppDomain, otherwise Unity can't deserialize the objects. It usually is possible to manually download a seperate external assembly file and use reflection to load that assembly into the current AppDomain. Once that has been done there should be no problem loading AssetBundles which contain gameobjects with components defined inside that assembly.

See this question for reference

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 G-Reusch · Aug 04, 2017 at 03:07 AM 0
Share

I'm glad to hear that what we're going for isn't just possible, but also intended! Thank you for the very thorough explanation too!

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

87 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

Related Questions

How to modify "resources.assets" (or alternative?) 2 Answers

How do you associate a Material Picker to prefab placed in scene from AssetBundles 0 Answers

how can I export a prefab modified from fbx model? 2 Answers

What does this mean exactly? "A script behaviour (script unknown or not yet loaded) has a different serialization layout when loading" 0 Answers

Modern Asset Handling - Multiple Projects? 0 Answers


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