Best way to dynamically load Assets in Unity WebGL Builds from external Source during Runtime - unity3d

Ive got a Unity WebGL Build with alot of Assets (1k+) that keep increasing. Everytime a new Asset gets added the whole Thing has to be built again which takes a lot of Time.
I only need a small Amount of the Assets during Runtime but i cant know which Assets exactly (The User can decide which Assets to actually use and see during Runtime).
Ive heard about Asset Bundles but i dont quite understand them yet. Is it possible to have some Sort of external Server running on its own with all the Assets there and then have the WebGL Build load the specific Assets it needs during Runtime from that Server?

You can use Addressable Asset System with remote catalog for dynamic asset delivery using any CDN. Every time you run your game Addressable Asset System will download assets dynamically & asynchronously. This feature is successor of old asset bundle system.

Related

Unity WebGL Build size increased with version upgrade (2018.4)

My Unity project builds to about 16MB for WebGL. I have a build script that enforces settings such as build size, compression, included scenes (we use asset bundling), and more.
When switching from 2018.2 to 2018.4 my build size went from 16MB to 40MB. I have double checked all the build settings, scene inclusion and asset bundle settings. Everything is the same.
I cannot find any reason why it would be so large, or any related issues on the forums / questions. Any ideas of where to start? Happy to provide settings in full if that would help.
I tried on both a windows and mac with same results.
The issue was the introduction of nested prefabs between 2018.2 and 2018.4. I had a build script that removed my theme song audio files from a prefab on my first scene, so that it could be loaded from an asset bundle on webgl. On 2018.2 the prefab auto saved and this was fine, the audio files were taken out of the build so it only existed in the asset bundle, on 2018.4 however you have to manually save the prefab, so the large audio files existed in the build as well as my asset bundle.
note: for those curious, i dont use asset bundles for iOS or Android so thats why i leave the audio files in the first scene. I have a custom webgl build script

Unity load a font from the disk or the web

This font needs to be dynamically changed so I can't put it in Resources.
I haven't found any resources or way to achieve this, all talk about Resources.
EDIT: I did look into AssetBunble but it looked overkill so I thought maybe requiring the user to install the font on his machine but Font.CreateDynamicFontFromOSFont does nothing. Whatever the given input (even invalid), it will always return the same "Arial" font and nothing visually change.
I might look into AssetBundles again but I don't want Unity installed on the target machine and if I understood right, you can't build an assetbundle without running Unity.
There is no Unity API to load standard font from disk or web into Unity's Font.
If you use Font.CreateDynamicFontFromOSFont, the font must be installed on the device. This is easy to do on some platforms like Windows but extremely hard on devices like Android.
The recommended way to do this is to use AssetBundles. You will need the Unity Editor to create the AssetBundles but you don't need it to load the AssetBundles during run-time. Put the fonts in AssetBundles then build it and host it on the server. Use UnityWebRequest API to download the Assetbundle then extract the font from it. You can always update this Assetbundle on the server.
If you want the user to to able to load the font from any source, you can automate the building part by asking the user where the font is, take that font and send/upload it to your server with the UnityWebRequest API. On the server side, run Unity Editor in a headless mode, retrieve the font sent to it and build an Assetbundle from it then send it back to the player and load it on the client side.
So, UnityWebRequestAssetBundle.GetAssetBundle is used to download the AssetBundle and AssetBundle.LoadAssetAsync is used to the fonts in it.
There is no other way to do this unless you have the Unity source code which is really expensive. By doing it this way, you won't need the font to be installed and won't run into issues on mobile devices. This post shows how to build and load an Assetbundle but you have to do that in headless mode.

AssetBundle (DLC) data load to Android phone at runtime [UNITY] [duplicate]

This question already has an answer here:
Download AssetBundle in hard disk
(1 answer)
Closed 4 years ago.
I'm using Asset Browser of Unity. I want to reduce my game. So I should make Asset Bundle(DLC) and when i click download button in phone, datas will download and load to phone as permanantly, it will download at once, after that user can play as offline. I builded my data in Asset Browser. how can i load it?
First, you need to build the asset bundles (with Asset bundle browser) and put them in a server that is publicly accesible. You need to use UnityWebRequest in your game to download your assetbundle from the server.
https://docs.unity3d.com/Manual/UnityWebRequest-DownloadingAssetBundle.html
Or you can use Unity Asset Bundle Manager (EDIT: Looks like Unity removed it from the asset store)
However, I have found this awesome tool, that I am actually using too, and it does a way better job. Just read the README, it is pretty straightforward. You just have to set the URL of your bundles, and then download bundles by specifying their name.
https://github.com/SadPandaStudios/AssetBundleManager

Unity - Uploading and downloading files in a game using a GUI

Is it possible in Unity to upload and download files while in a game? I want to make a minecraft-style building game and allow the user to import and use their own models (.obj files, etc), while in the game. I've been using Playfab for a backend and Photon for online cabilities, but as far as I can tell it will only work with image files (in Playfab). Is there a way to accomplish this and what would I need to use?
Yes, the way to go is to use Asset Bundles
Asset Bundles are platform specific assets that you create in Unity, but that you don't put in your build. Instead you can download them later, just as you want.
The process is a bit long, but not that difficult. The unity manual is actually really good and it should be easy to follow. Here is the link:
Asset Bundles documentation

SpriteKit texture atlases without including in bundle

I see that SpriteKit expects its texture atlases to be within the application bundle. However I am downloading game assets over the internet. Is there a way to load the asset bundle from memory or through another method that allows this?
I already create SKTexture instances from assets downloaded over the internet, but I would love to get the performance boost from using atlases.
Unfortunately, no.
You can roll your own spritesheets but you can't use the built in functionality for an atlas that isn't in the bundle.
I solved this problem by downloading all of my non-atlas assets after install but shipping with all of the atlases to keep the IPA under 100MB.
iOS 9 support On Demand Resources, which might supply the functionality you are looking for. The primary purpose of this technology (part of App Thinning) is to reduce the bundle size when installing the app.