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
5
Question by baha · Jan 30, 2010 at 07:51 PM · buildassetbundle

How to build asset bundles at runtime from a server?

i was wondering if there is a way to create asset bundles at runtime? i want my server to create asset bundles at runtime, is it possible in any way?

I thought that i may use unity Pro and customize the build pipeline to build asset bundles but how can i make it run on the server and call it with given parameters to import specific content from a specific path as an asset bundle with a specific name and add the result to a specific location or on a database? is this solution possible and if yes,how? and are there any better ways to do such a functionallity? please advice

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

5 Replies

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

Answer by Ben 2 · Apr 07, 2010 at 02:40 PM

I think the process of building the bundle on the fly might be slower than you anticipate if you don't expect your users to have to wait. We build asset bundles on a server as part of our build process (not for runtime on-the-fly builds) and it takes a few minutes but we have a lot of images and a few hundred xml files.

Anyway, to do this you need to run Unity from the command line like so:

${UNITY_EXEC} -batchmode -quit -projectProject ${ASSET_BUNDLE_PROJECT_DIR} -executeMethod ExportResourcesToBundle.Export;

This is copied from a bash script I wrote so you'd want to specify ${UNITY_EXEC} to be the location of your Unity executable and ${ASSET_BUNDLE_PROJECT_DIR} is the name of a temporary project that we create to store the content that comes in from SVN.

ExportResourcesToBundle.Export is generated on the fly. The class contains a static method that figures out the assets to bundle and ultimately calls BuildPipeline.BuildAssetBundle(...). As someone else pointed out, its a static method that takes no arguments but its easy to pass "arguments" in if you're generating the class on the fly. We just use bash variables and cat out the class into the file ExportResourcesToBundle under Assets/Editor in the project.

If you do all this in a script on the server its easy to just run your script and after a few seconds or minutes you have an asset bundle.

Hope that helps.

Comment
Add comment · Show 2 · 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 netjunki · Apr 14, 2011 at 10:15 PM 0
Share

Do you have more details on this process? For example how would you go about creating the temporary project? I'd be really curious to see a tutorial on this topic that outlines the whole process from start to finish.

avatar image alok-kr-029 · Mar 21, 2016 at 11:13 AM 0
Share

Hey can you elaborate the way of passing argument through command line to Unity. I am however able to call the script through the command Line , I just want to pass argument to the script.

avatar image
2

Answer by jonas-echterhoff · Feb 01, 2010 at 11:21 AM

The best way to do this would probably to create some sort of server, which starts the Unity Editor in batch mode using the command line, invoking a custom editor build script, which builds your Asset Bundles. Whether or not this is feasible, really depends on what kinds of response times you require, and how often you need to create these custom asset bundles.

Maybe if you describe in more detail what you need this for, people will be able to bring up better suggestions.

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
1

Answer by Ashkan_gc · Feb 15, 2010 at 03:55 PM

as jonas said unity's runtime engine can not create asset bundles. you should use the editor build asset bundles. the only way to do this remotely is via editor scripts. unity has a command line argument that enables you to run unity and execute an editor script in it. unity will do the job and quit ifyou want. you should use -executemethod and then provide classname.methodname. the scritpt should be in editor folder and the function should be static. you can not send arguments to the function. to do that you should write in a file or db and read it in unity. this is an slow process and might not be what you want but you should describe it more to help others.

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 JairoGLoz · Feb 27, 2018 at 07:20 PM

Hi @Ben 2 , @jonas-echterhoff and @Ashkan_gc, any news on this matter? I'm about to start following the steps you described here to mount a server able to create AssetBundles at runtime, but I'm completely new to this, so if anyone knows of any other resource I can look at, or an easier or more recent way of doing this it would be really helpful for us.

I'll be happy to share more details on what I want to achieve if you need to know more.

Thanks in advance!

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 FaiyazOfficial · May 19, 2018 at 09:56 AM 0
Share

I am about to start the same . Did you manage to do it ?

avatar image
0

Answer by unity_fZwle-MWodWlVQ · Oct 10, 2018 at 05:16 AM

Hi @FaiyazOfficial @ben 2 @JairoGLoz do you found some solution? I also need such module which runs on server and store that bundle on some y address.

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

6 People are following this question.

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

Related Questions

Distribute terrain in zones 3 Answers

How to import the object from server to unity 2 Answers

How to correctly make AssetBundles for different build targets? 1 Answer

How to customize Addressables BuildPath or LoadPath through Code? 1 Answer

How can I upload AssetBundles to AWS S3 with Unity Cloud Build? 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