I’m at an early stage of a unity project and a thought occurred to me that could be a deal breaker for the entire project.
My final product will have a single character displayed on a screen with his/her armor pieces dynamically controlled by a character id fed into the url of the page.
As I have to be able to account for any combination of the hundreds of possible pieces that go onto these characters, I’m very concerned about the web client having to download every mesh piece and texture we’ve ever made to be able to do this.
So my questions:
A) Will a web player pull the entire contents of all my meshes in project folders before it displays on screen to the end user?
B) If so, is there a way to dynamically pull mesh render and material data from a web source on demand (packages would be out of the question as I can’t see us making literally 1,000+ downloadable asset packages)
The end result will be very similar to https://www.heroforge.com/
Thank you
To answer question A:
If you create a webbuild of your project, every asset that should be included in your build, will be compressed and packed into the .unity3d file. So yes, all models / textures / … you reference from a scene (that is included in the build settings) or that is located in a resources folder will be part of your build and will be loaded when the game is run.
However there are some things you should remember:
- Assets in resources folders are loaded right at the beginning, since Unity can’t know when you want to load one of these. If you have a lot of content, don’t use “resources” folders.
- If you build your webplayer as a streaming webplayer, the game will start as soon as the first scene (scene 0) has finished loading. That means the game starts while the rest of the webplayer file is still loaded in the background. You can check if a certain level has finished downloading with Application.CanStreamedLevelBeLoaded or GetStreamProgressForLevel. So a solution here could be to spread assets across multiple levels and load them (once they finished downloading) additively when needed.
To answer question B:
Unity has no support at runtime for loading models / mesh data besides AssetBundles. If you have a loader for a certain file format (.OBJ loader for example) you can roll your own content loading system. If you have Unity pro, AssetBundles are probably the best solution as they allow loading precreated and verified models including animations, materials, textures, …
Keep in mind that you can create an Editor script which creates / updates the assetbundles for you. You have to use some naming convention anyways since you have to actually load the content from a server. The actual workflow highly depends on your input format (file format, file names, file locations) and your desired output.