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
1
Question by 230000751 · Oct 29, 2017 at 02:42 PM · strange ioc

Load new scripts (post-build) through Asset Bundles. Is this even possible?

Here we are to an age old question, but I'm going to re-address it anyway so please bare with me.

The only disappointing limitation on asset bundles that I can find is the inability to include newly created scripts with the objects in the bundle. Unfortunately for anyone who plans to implement any form of unique logic after a build is in for a metaphorical brick wall.

To put this simply, think of a fighting game with a bunch of different characters (like SSBB) there are characters included in the initial build, but then there are downloadable characters as well. And what makes it so good is that though they all may share the same core mechanics (like base classes in unity) they all function pretty unique from one another and they perform different actions that others cannot.

To achieve this in unity, you could inherit from a base class that is already compiled in the build, but ultimately rely on a newly scripted behavior specific to that character. The question is how can you make an operable character like this for an asset bundle?


Since asset bundles don't support new scripts, I researched and found some potential solutions which point to saving the new scripts as .bytes files and using Reflections to load the behavior at runtime. This may work, but everywhere I look seems to gloss over the main details of actually turning a script into a .bytes file in the first place. Ex. https://docs.unity3d.com/412/Documentation/Manual/binarydata.html

And just say that works, how do we even go about doing this in the first place? If we do manage to succeed in loading a new script, wouldn't that remove any public values you may have assigned to the classes and prefab before exporting to the bundle? The whole process seems perplexing at the moment. And unfortunately the implementation of unique characters and abilities is a crucial feature in the game me and my team are working on.


I know that this is not a new issue, and a lot of people have asked this question before (some people managing to find a workaround somehow). What can be done to make this happen? Is it even worthwhile to attempt this or would it be more efficient to just create the new scripts in the original build (excluding the characters and/or items they are attached to [which will still be separate objects in downloadable asset bundles]), and just export a new update (new build of the original game, now including the required scripts) as an update to be installed and then download the asset bundles which will then function properly?

It just seems like the latter will be more taxing considering that every added level will probably use some new form of scripting (even though it may be a very simple script simply for map aesthetics)


I hope the question is clear and that we can find a solution.

Comment
Add comment · Show 5
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 Bonfire-Boy · Oct 29, 2017 at 03:33 PM 0
Share

I suggest you take a look at the Playmaker plugin. I've used it to do exactly the sort of thing you're describing, adding completely new $$anonymous$$i-games to a published game via asset bundles, with no need to change the published build.

avatar image Bonfire-Boy Bonfire-Boy · Oct 29, 2017 at 03:37 PM 0
Share

I should perhaps clarify that the published build did need to have the Playmaker code in it, and the stuff I'd written to connect my $$anonymous$$i-games to the game as a whole.

avatar image Glurth · Oct 29, 2017 at 03:40 PM 0
Share

Regarding the last option you mentioned: Rather than rebuild the whole project, for redistribution, use a DLL. Then, you can rebuild just the DLL, and distribute it with the update, overwriting the original DLL file, to replace the behaviors. Obviously, you don't need ALL your code in the dll, just the code you expect to update regularly.

avatar image 230000751 Glurth · Oct 30, 2017 at 05:42 PM 0
Share

Dlls would be a first for me but definitely worth looking into.

avatar image TonyLi · Oct 30, 2017 at 07:32 PM 0
Share

You can probably use this gist by Paul Hayes to import the DLL at runtime: https://gist.github.com/paulhayes/06435c009d8ae2d305cc7d9e2f6cc1b7

However, some studios write their character logic in a higher level interpreted language such as Lua, to which they've exposed specific game framework functions that they've written in C#. It's similar to Bonfire-Boy's Play$$anonymous$$aker suggestion, but it lets you write text-based code ins$$anonymous$$d of using visual scripting if you prefer that. You can include these scripts as text files in your assetbundles, and feed them to the interpreted language at runtime. There are several Lua packages on the Asset Store: https://www.assetstore.unity3d.com/en/#!/search/page=1/sortby=relevance/query=lua

0 Replies

· Add your reply
  • Sort: 

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

75 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

Related Questions

Avoiding Bloom Pop 1 Answer

Enabling disabling objects via raycast 0 Answers

How to create an Animated 2D Line to help the user aim and shoot? 0 Answers

Compiler failed to execute. 1 Answer

How to make a script slow down to a stop 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