mirror of https://github.com/Cysharp/UniTask
feat: add Localization extensions
parent
2e225fb841
commit
996a2cfa5b
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d2a30a3e9c8f5c0479d5aa1b92caeb64
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
32
src/UniTask/Assets/Plugins/UniTask/Runtime/External/Localization/LocalizationAsyncExtensions.cs
vendored
Normal file
32
src/UniTask/Assets/Plugins/UniTask/Runtime/External/Localization/LocalizationAsyncExtensions.cs
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
#if UNITASK_LOCALIZATION_SUPPORT
|
||||
|
||||
using Cysharp.Threading.Tasks.Linq;
|
||||
using UnityEngine.Localization;
|
||||
|
||||
namespace Cysharp.Threading.Tasks
|
||||
{
|
||||
public static partial class LocalizationAsyncExtensions
|
||||
{
|
||||
public static IUniTaskAsyncEnumerable<string> OnValueChangedAsAsyncEnumerable(
|
||||
this LocalizedString localizedString)
|
||||
{
|
||||
return UniTaskAsyncEnumerable.Create<string>(async (writer, cancellationToken) =>
|
||||
{
|
||||
async void Handler(string newValue)
|
||||
{
|
||||
await writer.YieldAsync(newValue);
|
||||
}
|
||||
|
||||
localizedString.StringChanged += Handler;
|
||||
cancellationToken.Register(() => localizedString.StringChanged -= Handler);
|
||||
|
||||
while (!cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
await UniTask.Yield();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b2739fb850114ecca748faa678ee0ee1
|
||||
timeCreated: 1714073055
|
24
src/UniTask/Assets/Plugins/UniTask/Runtime/External/Localization/UniTask.Localization.asmdef
vendored
Normal file
24
src/UniTask/Assets/Plugins/UniTask/Runtime/External/Localization/UniTask.Localization.asmdef
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"name": "UniTask.Localization",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:f51ebe6a0ceec4240a699833d6309b23",
|
||||
"GUID:eec0964c48f6f4e40bc3ec2257ccf8c5",
|
||||
"GUID:5c01796d064528144a599661eaab93a6"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [
|
||||
{
|
||||
"name": "com.unity.localization",
|
||||
"expression": "",
|
||||
"define": "UNITASK_LOCALIZATION_SUPPORT"
|
||||
}
|
||||
],
|
||||
"noEngineReferences": false
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 966856f46ac0e9642a80e1d2352ea9fc
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Reference in New Issue