Fonts in Asset Bundles Documentation
- JohnLawrie
- Topic Author
- Offline
- New Member
Less
More
- Posts: 9
- Thank you received: 0
8 years 1 month ago #1864
by JohnLawrie
Fonts in Asset Bundles Documentation was created by JohnLawrie
Is there any documentation about how to use the asset bundle features of I2 Localization to put fonts in asset bundles. Maybe I'm missing something, but I don't see any documentation about it at
www.inter-illusion.com/assets/I2Localiza...alizationManual.html
Thanks
John Lawrie
Thanks
John Lawrie
Please Log in or Create an account to join the conversation.
8 years 1 month ago #1866
by Frank
Are you Give I2L 5 stars!
Are you Please lets us know how to improve it!
Replied by Frank on topic Fonts in Asset Bundles Documentation
Hi,
Sorry, I haven't documented it too much (if anything) aside of the example in
Assets\I2\Localization\Examples\Common\Scripts\RegisterBundlesManager.cs
The basic idea is that if you are loading AssetBundles and want to allow I2 Localization to access assets inside those bundles, then you have to create a class similar to the RegisterBundlesManager and add that into one of your scenes.
That class should implement the LoadFromBundle function that given the name/path of the asset it should load it and return it for I2 Localization to use it:
For example:
That approach works fine if you are managing your AssetBundles already.
For those who are not managing them, In one of the next release (most likely 2.7.0) I'm going to add a CustomAssetBundleManager, that could do Async loading (e.g. the plugin request the asset, if the bundle is not loaded yet, then it is downloaded and loaded, and at that point the localization runs again)
Hope that helps. And I'm going to write this section in the Documentation (I was waiting for finishing the CustomAssetBundleManager, and then write the complete doc, but I will do a draft so that it can help others while the full version is done!)
Frank
Sorry, I haven't documented it too much (if anything) aside of the example in
Assets\I2\Localization\Examples\Common\Scripts\RegisterBundlesManager.cs
The basic idea is that if you are loading AssetBundles and want to allow I2 Localization to access assets inside those bundles, then you have to create a class similar to the RegisterBundlesManager and add that into one of your scenes.
That class should implement the LoadFromBundle function that given the name/path of the asset it should load it and return it for I2 Localization to use it:
For example:
public class MyBundlesManager : RegisterBundlesManager
{
public override T LoadFromBundle<T>(string path) where T : Object
{
// load from a bundle using path and return the object
return null; // return null if the object was not found in the bundles
}
}
That approach works fine if you are managing your AssetBundles already.
For those who are not managing them, In one of the next release (most likely 2.7.0) I'm going to add a CustomAssetBundleManager, that could do Async loading (e.g. the plugin request the asset, if the bundle is not loaded yet, then it is downloaded and loaded, and at that point the localization runs again)
Hope that helps. And I'm going to write this section in the Documentation (I was waiting for finishing the CustomAssetBundleManager, and then write the complete doc, but I will do a draft so that it can help others while the full version is done!)
Frank
Are you Give I2L 5 stars!
Are you Please lets us know how to improve it!
To get the betas as soon as they are ready,
check this out
Please Log in or Create an account to join the conversation.
3 years 11 months ago #4205
by nindim
Replied by nindim on topic Fonts in Asset Bundles Documentation
Hi Frank,
I know this thread is old, but I am struggling with moving my font assets to Addressables and this seems to be the closest thing to what I need.
I have tried following the documentation you added ( www.inter-illusion.com/assets/I2Localiza...anual/AssetsTab.html ), but I can't find anyway to use the System.Type with the Addressables load functions.
I have modified:
to:
and this allows me to load via:
but given that there is no synchronous loading in the Addressables API, it doesn't really fit with how this is all setup...
Preloading would perhaps allow the AsyncOperationHandle.Result to return immediately but there is a very real risk of locking the main thread in the case that you forget to preload the font's bundle and this seems more like a hack than a solution.
How to release the AsyncOperationHandle and decrease the ref count on the Addressables dependencies is the next question as I don't want to keep unused fonts in memory, for example when the language is switched.
The CustomAssetBundleManager sounds like it could be exactly what I need, but it doesn't seem to have made its way into any release since you mentioned it?
Hopefully you can help anyway as other than these fonts (and the TMP default font), I have managed to move everything to Addressables now.
Thanks a lot,
Niall
I know this thread is old, but I am struggling with moving my font assets to Addressables and this seems to be the closest thing to what I need.
I have tried following the documentation you added ( www.inter-illusion.com/assets/I2Localiza...anual/AssetsTab.html ), but I can't find anyway to use the System.Type with the Addressables load functions.
I have modified:
public virtual Object LoadFromBundle(string path, System.Type assetType )
to:
public virtual Object LoadFromBundle<T>(string path) where T : UnityEngine.Object
and this allows me to load via:
Addressables.LoadAssetAsync<T>(key)
but given that there is no synchronous loading in the Addressables API, it doesn't really fit with how this is all setup...
Preloading would perhaps allow the AsyncOperationHandle.Result to return immediately but there is a very real risk of locking the main thread in the case that you forget to preload the font's bundle and this seems more like a hack than a solution.
How to release the AsyncOperationHandle and decrease the ref count on the Addressables dependencies is the next question as I don't want to keep unused fonts in memory, for example when the language is switched.
The CustomAssetBundleManager sounds like it could be exactly what I need, but it doesn't seem to have made its way into any release since you mentioned it?
Hopefully you can help anyway as other than these fonts (and the TMP default font), I have managed to move everything to Addressables now.
Thanks a lot,
Niall
Please Log in or Create an account to join the conversation.
3 years 11 months ago #4208
by Frank
Are you Give I2L 5 stars!
Are you Please lets us know how to improve it!
Replied by Frank on topic Fonts in Asset Bundles Documentation
At the moment when the ResourceManager was created, Addressables were not yet a "thing", so it doesn't support async loading of objects.
I'm going to try adding that asap to the plugin and upload a new version.
In the meantime, one way around is to write your own BundlesManager that when gets a LoadFromBundle call, it starts loading async the object and just returns null.
Then, when all the objects are loaded, it places them in a cache dictionary and calls the LocalizationManager to update the localization. That will trigger the call to LoadFromBundle again and this time you already have the object you need in the cache, so you return it and the plugin will be able to use it.
Its not the best option, but at least will allow you to move forward until the next release is out.
Hope that helps,
Frank
I'm going to try adding that asap to the plugin and upload a new version.
In the meantime, one way around is to write your own BundlesManager that when gets a LoadFromBundle call, it starts loading async the object and just returns null.
Then, when all the objects are loaded, it places them in a cache dictionary and calls the LocalizationManager to update the localization. That will trigger the call to LoadFromBundle again and this time you already have the object you need in the cache, so you return it and the plugin will be able to use it.
Its not the best option, but at least will allow you to move forward until the next release is out.
Hope that helps,
Frank
Are you Give I2L 5 stars!
Are you Please lets us know how to improve it!
To get the betas as soon as they are ready,
check this out
Please Log in or Create an account to join the conversation.
3 years 10 months ago #4214
by Koya
Replied by Koya on topic Fonts in Asset Bundles Documentation
Hi, I've been facing the same situation.
How do I trigger the call to LoadFromBundle again after loading assets by Addressable?
How do I trigger the call to LoadFromBundle again after loading assets by Addressable?
Please Log in or Create an account to join the conversation.
3 years 9 months ago #4224
by Frank
Are you Give I2L 5 stars!
Are you Please lets us know how to improve it!
Replied by Frank on topic Fonts in Asset Bundles Documentation
Hi,
I2 Localization has no build in support for Addressables, but it can work exactly as any other of your assets.
If you add the LanguageSource to a bundle or mark it as addressable, it will be bundled, and then you just need to instantiate/load it on startup. As soon as is loaded from the bundle it will auto-register in the localization manager.
So, just create an script that on Start loads the LanguageSource from your bundle and all its terms will be available to the LocalizationManager.
Said that, I will add in the next release an example of how to set that up and have an script to auto-load from addressable on startup.
I2 Localization has no build in support for Addressables, but it can work exactly as any other of your assets.
If you add the LanguageSource to a bundle or mark it as addressable, it will be bundled, and then you just need to instantiate/load it on startup. As soon as is loaded from the bundle it will auto-register in the localization manager.
So, just create an script that on Start loads the LanguageSource from your bundle and all its terms will be available to the LocalizationManager.
Said that, I will add in the next release an example of how to set that up and have an script to auto-load from addressable on startup.
Are you Give I2L 5 stars!
Are you Please lets us know how to improve it!
To get the betas as soon as they are ready,
check this out
Please Log in or Create an account to join the conversation.
Time to create page: 0.168 seconds