From 31b7b6768ebc7159556eaf7b0bfad1e2b20d654a Mon Sep 17 00:00:00 2001 From: TippingGame Date: Wed, 6 Nov 2024 03:06:24 +0800 Subject: [PATCH] =?UTF-8?q?1.0.57=201.#18=20=E6=9C=AC=E5=9C=B0=E5=8C=96?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E4=B8=8D=E5=86=8D=E4=BE=9D=E8=B5=96=E8=B5=84?= =?UTF-8?q?=E4=BA=A7=EF=BC=8C=E5=8F=AF=E4=BD=BF=E7=94=A8id=E7=B4=A2?= =?UTF-8?q?=E5=BC=95=E8=B5=84=E4=BA=A7=E3=80=82=E5=A6=82=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=A4=9A=E5=BC=A0=E5=9B=BE=E7=89=87=EF=BC=8C=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E5=8F=AA=E9=9C=80=E8=A6=81=E4=B8=80=E4=B8=AAid=EF=BC=8C2.?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=B5=84=E4=BA=A7=E6=A8=A1=E5=9D=97=E5=B1=95?= =?UTF-8?q?=E5=BC=80=E8=B5=84=E6=BA=90=E6=97=B6=E7=B1=BB=E5=9E=8B=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AssetMap/Resources/AssetBundleMap.json | 2 +- CHANGELOG.md | 4 + .../Localization/AudioLocalizerInspector.cs | 84 ++++++++++++++++-- .../Localization/ImageLocalizerInspector.cs | 87 ++++++++++++++++++- Editor/Localization/TextLocalizerInspector.cs | 2 +- .../TextLocalizerPlayableAssetInspector.cs | 2 +- .../AssetBundleManager/AssetBundleLoader.cs | 77 ++++++++++++---- .../AssetBundleManager/AssetBundleManager.cs | 13 +-- Runtime/AssetManager/AssetManager.cs | 50 +++++------ Runtime/Localization/Audio/AudioLocalizer.cs | 35 +++++++- .../Localization/Audio/AudioSourceInjector.cs | 36 ++++++-- Runtime/Localization/Image/ImageLocalizer.cs | 43 +++++++-- .../Localization/Image/RawImageInjector.cs | 24 ++++- .../Image/SpriteRendererInjector.cs | 24 ++++- Runtime/Localization/Image/TextureInjector.cs | 24 ++++- Runtime/Localization/Image/UIImageInjector.cs | 24 ++++- Tests/GameObjectPool/DemoGameObjectPool.cs | 4 +- .../SimpleWebTransport/ExampleWebClient.cs | 2 +- .../SimpleWebTransport/ExampleWebServer.cs | 4 +- Tests/Tween/DemoTween.cs | 2 + package.json | 2 +- 21 files changed, 458 insertions(+), 87 deletions(-) diff --git a/AssetMap/Resources/AssetBundleMap.json b/AssetMap/Resources/AssetBundleMap.json index c364870..e17bcf1 100644 --- a/AssetMap/Resources/AssetBundleMap.json +++ b/AssetMap/Resources/AssetBundleMap.json @@ -1 +1 @@ -{"2852":{"AbName":"audio/2852","AssetPath":["assets/assetbundles/audio/2852.wav"],"Version":"1.0.0","Size":"5328","MD5":"6567562ee60b08264082fbaf4a0eea8b","Package":"","Updated":""},"button1":{"AbName":"audio/button1","AssetPath":["assets/assetbundles/audio/button1.wav"],"Version":"1.0.0","Size":"15566","MD5":"8c9400e8733649c19c43e13accf405f4","Package":"","Updated":""},"\u5927\u98CE-WQ20070525":{"AbName":"audio/\u5927\u98CE-wq20070525","AssetPath":["assets/assetbundles/audio/\u5927\u98CE-wq20070525.mp3"],"Version":"1.0.0","Size":"985351","MD5":"d9423efa43a50cd8d5f1221cb9938c1d","Package":"","Updated":""},"\u7B1B\u5B501-mcx20070508":{"AbName":"audio/\u7B1B\u5B501-mcx20070508","AssetPath":["assets/assetbundles/audio/\u7B1B\u5B501-mcx20070508.wav"],"Version":"1.0.0","Size":"9759","MD5":"c6d28f576e5d39c8a09267ab707109a0","Package":"","Updated":""},"F8Framework.F8ExcelDataClass":{"AbName":"code/f8framework.launcher","AssetPath":["assets/assetbundles/code/f8framework.f8exceldataclass.bytes"],"Version":"1.0.0","Size":"7085","MD5":"e750e0a92e1f9f762bddf57ce0253615","Package":"","Updated":""},"00029-3980031510mat":{"AbName":"materials/00029-3980031510mat","AssetPath":["assets/assetbundles/materials/00029-3980031510mat.mat"],"Version":"1.0.0","Size":"148297","MD5":"ecb4e07b867022a11e1f402a559230a0","Package":"","Updated":""},"00031-1829375853mat":{"AbName":"materials/00031-1829375853mat","AssetPath":["assets/assetbundles/materials/00031-1829375853mat.mat"],"Version":"1.0.0","Size":"343567","MD5":"05b65e6a31f5a135fc83709d43d982ae","Package":"","Updated":""},"New Material":{"AbName":"materials/new material","AssetPath":["assets/assetbundles/materials/new material.mat"],"Version":"1.0.0","Size":"21826","MD5":"22d43598d856c5df80d4c4988d5019a8","Package":"","Updated":""},"uibg":{"AbName":"package_0/uibg","AssetPath":["assets/assetbundles/package_0/uibg.mat"],"Version":"1.0.0","Size":"19073","MD5":"60916d80a97779ba70393b2abee635da","Package":"0","Updated":""},"uibg 1":{"AbName":"package_1/uibg 1","AssetPath":["assets/assetbundles/package_1/uibg 1.mat"],"Version":"1.0.0","Size":"19061","MD5":"35a1ad349c1eba332bda2b5190e7d3c0","Package":"1","Updated":""},"Cube":{"AbName":"prefabs/cube","AssetPath":["assets/assetbundles/prefabs/cube.prefab"],"Version":"1.0.0","Size":"3451","MD5":"0bc24c2bd3837acb51ded6864a768e71","Package":"","Updated":""},"Cube1":{"AbName":"prefabs/cube1","AssetPath":["assets/assetbundles/prefabs/cube1.prefab"],"Version":"1.0.0","Size":"3487","MD5":"974da21064a3e2adc97e7980854534ae","Package":"","Updated":""},"Cube2":{"AbName":"prefabs/cube2","AssetPath":["assets/assetbundles/prefabs/cube2.prefab"],"Version":"1.0.0","Size":"43897","MD5":"ad9d3395073decfa05a2f1584060eebc","Package":"","Updated":""},"Pools":{"AbName":"prefabs/pools","AssetPath":["assets/assetbundles/prefabs/pools.prefab"],"Version":"1.0.0","Size":"2830","MD5":"e3a6c9e484b02df8d2c68f5aa11e24fd","Package":"","Updated":""},"PoolsPreset":{"AbName":"prefabs/poolspreset","AssetPath":["assets/assetbundles/prefabs/poolspreset.asset"],"Version":"1.0.0","Size":"2135","MD5":"13a66491873c0f19b5e4d708f0829ae9","Package":"","Updated":""},"SphereA":{"AbName":"prefabs/spherea","AssetPath":["assets/assetbundles/prefabs/spherea.prefab"],"Version":"1.0.0","Size":"3084","MD5":"6d5e266fe11b0fc0c01e5cd04f6f3308","Package":"","Updated":""},"xiaochong":{"AbName":"prefabs/xiaochong","AssetPath":["assets/assetbundles/prefabs/xiaochong.prefab"],"Version":"1.0.0","Size":"17177","MD5":"322347450586a5c27e9d48334fa469a3","Package":"","Updated":""},"00023-3589759801":{"AbName":"textures/00023-3589759801","AssetPath":["assets/assetbundles/textures/00023-3589759801.png"],"Version":"1.0.0","Size":"48503","MD5":"12c0064ab5941707445888ff526af03d","Package":"","Updated":""},"00029-3980031510":{"AbName":"textures/00029-3980031510","AssetPath":["assets/assetbundles/textures/00029-3980031510.png"],"Version":"1.0.0","Size":"109897","MD5":"3e3841a65b3af8dd1588145ec9be01cc","Package":"","Updated":""},"00031-1829375853":{"AbName":"textures/00031-1829375853","AssetPath":["assets/assetbundles/textures/00031-1829375853.png"],"Version":"1.0.0","Size":"305231","MD5":"9680d5ff52fa854e97c6a9355f78d943","Package":"","Updated":""},"sdfadasd":{"AbName":"ui/sdfadasd","AssetPath":["assets/assetbundles/ui/sdfadasd.unity"],"Version":"1.0.0","Size":"50502","MD5":"21cf8a6727731d8a5a26e16d5799d561","Package":"","Updated":""},"UIPanel":{"AbName":"ui/uipanel","AssetPath":["assets/assetbundles/ui/uipanel.prefab"],"Version":"1.0.0","Size":"647827","MD5":"868b3d2439a01b6914fa6e24cd1f8203","Package":"","Updated":""},"LocalizedStrings":{"AbName":"config/binconfigdata/localizedstrings","AssetPath":["assets/assetbundles/config/binconfigdata/localizedstrings.bytes"],"Version":"1.0.0","Size":"4223","MD5":"cd4c01d0d3f2aa1b82b3905f487edcfc","Package":"","Updated":""},"Sheet1":{"AbName":"config/binconfigdata/sheet1","AssetPath":["assets/assetbundles/config/binconfigdata/sheet1.bytes"],"Version":"1.0.0","Size":"1873","MD5":"825a2478b5167c75ba1e4d30a9136471","Package":"","Updated":""},"Sheet2":{"AbName":"config/binconfigdata/sheet2","AssetPath":["assets/assetbundles/config/binconfigdata/sheet2.bytes"],"Version":"1.0.0","Size":"1943","MD5":"3e4ecedee812012815e392eccc330991","Package":"","Updated":""},"Cube1fsdf":{"AbName":"prefabs/pf2/aqq","AssetPath":["assets/assetbundles/prefabs/pf2/cube1fsdf.prefab"],"Version":"1.0.0","Size":"3731","MD5":"78d16003e941a13c17ad3db70458cb8e","Package":"","Updated":""},"Cube2sdfwe":{"AbName":"prefabs/pf2/cube2sdfwe","AssetPath":["assets/assetbundles/prefabs/pf2/cube2sdfwe.prefab"],"Version":"1.0.0","Size":"46022","MD5":"49ab6481a11fc6aba6d30899808ef275","Package":"","Updated":""},"Cubeljk":{"AbName":"prefabs/pf2/aqq","AssetPath":["assets/assetbundles/prefabs/pf2/cubeljk.prefab"],"Version":"1.0.0","Size":"3731","MD5":"78d16003e941a13c17ad3db70458cb8e","Package":"","Updated":""},"Audio":{"AbName":"","AssetPath":["2852","button1","\u5927\u98CE-WQ20070525","\u7B1B\u5B501-mcx20070508"],"Version":"1.0.0","Size":"","MD5":"","Package":"","Updated":""},"Code":{"AbName":"","AssetPath":["F8Framework.F8ExcelDataClass"],"Version":"1.0.0","Size":"","MD5":"","Package":"","Updated":""},"Config":{"AbName":"","AssetPath":[],"Version":"1.0.0","Size":"","MD5":"","Package":"","Updated":""},"Materials":{"AbName":"","AssetPath":["00029-3980031510mat","00031-1829375853mat","New Material"],"Version":"1.0.0","Size":"","MD5":"","Package":"","Updated":""},"Package_0":{"AbName":"","AssetPath":["uibg"],"Version":"1.0.0","Size":"","MD5":"","Package":"","Updated":""},"Package_1":{"AbName":"","AssetPath":["uibg 1"],"Version":"1.0.0","Size":"","MD5":"","Package":"","Updated":""},"Prefabs":{"AbName":"","AssetPath":["Cube","Cube1","Cube2","Pools","PoolsPreset","SphereA","xiaochong"],"Version":"1.0.0","Size":"","MD5":"","Package":"","Updated":""},"Textures":{"AbName":"","AssetPath":["00023-3589759801","00029-3980031510","00031-1829375853"],"Version":"1.0.0","Size":"","MD5":"","Package":"","Updated":""},"UI":{"AbName":"","AssetPath":["sdfadasd","UIPanel"],"Version":"1.0.0","Size":"","MD5":"","Package":"","Updated":""},"BinConfigData":{"AbName":"","AssetPath":["LocalizedStrings","Sheet1","Sheet2"],"Version":"1.0.0","Size":"","MD5":"","Package":"","Updated":""},"pf2":{"AbName":"","AssetPath":["Cube1fsdf","Cube2sdfwe","Cubeljk"],"Version":"1.0.0","Size":"","MD5":"","Package":"","Updated":""},"Windows":{"AbName":"Windows","AssetPath":[],"Version":"1.0.0","Size":"2591","MD5":"bcd491670773570228fcf3aec9cf3928","Package":"","Updated":""}} \ No newline at end of file +{"2852":{"AbName":"audio/2852","AssetPath":["assets/assetbundles/audio/2852.wav"],"Version":"1.0.0","Size":"5328","MD5":"6567562ee60b08264082fbaf4a0eea8b","Package":"","Updated":""},"button1":{"AbName":"audio/button1","AssetPath":["assets/assetbundles/audio/button1.wav"],"Version":"1.0.0","Size":"15566","MD5":"8c9400e8733649c19c43e13accf405f4","Package":"","Updated":""},"\u3010Unity\u6846\u67B6\u3011\uFF0810\uFF09\u6E38\u620F\u5BF9\u8C61\u6C60":{"AbName":"audio/\u3010unity\u6846\u67B6\u3011\uFF0810\uFF09\u6E38\u620F\u5BF9\u8C61\u6C60","AssetPath":["assets/assetbundles/audio/\u3010unity\u6846\u67B6\u3011\uFF0810\uFF09\u6E38\u620F\u5BF9\u8C61\u6C60.mp4"],"Version":"1.0.0","Size":"302155131","MD5":"dd6cd4e821a424e35b0370c6408f2c85","Package":"","Updated":""},"\u5927\u98CE-WQ20070525":{"AbName":"audio/\u5927\u98CE-wq20070525","AssetPath":["assets/assetbundles/audio/\u5927\u98CE-wq20070525.mp3"],"Version":"1.0.0","Size":"1969029","MD5":"d2f796bab894c8c160403273edc0cc5c","Package":"","Updated":""},"\u5927\u98CE-WQ20070525_222":{"AbName":"audio/\u5927\u98CE-wq20070525","AssetPath":["assets/assetbundles/audio/\u5927\u98CE-wq20070525_222.mp3"],"Version":"1.0.0","Size":"1969029","MD5":"d2f796bab894c8c160403273edc0cc5c","Package":"","Updated":""},"\u7B1B\u5B501-mcx20070508":{"AbName":"audio/\u7B1B\u5B501-mcx20070508","AssetPath":["assets/assetbundles/audio/\u7B1B\u5B501-mcx20070508.wav"],"Version":"1.0.0","Size":"9759","MD5":"c6d28f576e5d39c8a09267ab707109a0","Package":"","Updated":""},"F8Framework.F8ExcelDataClass":{"AbName":"code/f8framework.launcher","AssetPath":["assets/assetbundles/code/f8framework.f8exceldataclass.bytes"],"Version":"1.0.0","Size":"7085","MD5":"e750e0a92e1f9f762bddf57ce0253615","Package":"","Updated":""},"00029-3980031510mat":{"AbName":"materials/00029-3980031510mat","AssetPath":["assets/assetbundles/materials/00029-3980031510mat.mat"],"Version":"1.0.0","Size":"148297","MD5":"ecb4e07b867022a11e1f402a559230a0","Package":"","Updated":""},"00031-1829375853mat":{"AbName":"materials/00031-1829375853mat","AssetPath":["assets/assetbundles/materials/00031-1829375853mat.mat"],"Version":"1.0.0","Size":"343567","MD5":"05b65e6a31f5a135fc83709d43d982ae","Package":"","Updated":""},"New Material":{"AbName":"materials/new material","AssetPath":["assets/assetbundles/materials/new material.mat"],"Version":"1.0.0","Size":"21826","MD5":"22d43598d856c5df80d4c4988d5019a8","Package":"","Updated":""},"uibg":{"AbName":"package_0/uibg","AssetPath":["assets/assetbundles/package_0/uibg.mat"],"Version":"1.0.0","Size":"19073","MD5":"60916d80a97779ba70393b2abee635da","Package":"0","Updated":""},"uibg 1":{"AbName":"package_1/uibg 1","AssetPath":["assets/assetbundles/package_1/uibg 1.mat"],"Version":"1.0.0","Size":"19061","MD5":"35a1ad349c1eba332bda2b5190e7d3c0","Package":"1","Updated":""},"Cube":{"AbName":"prefabs/cube","AssetPath":["assets/assetbundles/prefabs/cube.prefab"],"Version":"1.0.0","Size":"3451","MD5":"0bc24c2bd3837acb51ded6864a768e71","Package":"","Updated":""},"Cube1":{"AbName":"prefabs/cube1","AssetPath":["assets/assetbundles/prefabs/cube1.prefab"],"Version":"1.0.0","Size":"3487","MD5":"974da21064a3e2adc97e7980854534ae","Package":"","Updated":""},"Cube2":{"AbName":"prefabs/cube2","AssetPath":["assets/assetbundles/prefabs/cube2.prefab"],"Version":"1.0.0","Size":"43897","MD5":"ad9d3395073decfa05a2f1584060eebc","Package":"","Updated":""},"Pools":{"AbName":"prefabs/pools","AssetPath":["assets/assetbundles/prefabs/pools.prefab"],"Version":"1.0.0","Size":"2830","MD5":"e3a6c9e484b02df8d2c68f5aa11e24fd","Package":"","Updated":""},"PoolsPreset":{"AbName":"prefabs/poolspreset","AssetPath":["assets/assetbundles/prefabs/poolspreset.asset"],"Version":"1.0.0","Size":"2135","MD5":"13a66491873c0f19b5e4d708f0829ae9","Package":"","Updated":""},"SphereA":{"AbName":"prefabs/spherea","AssetPath":["assets/assetbundles/prefabs/spherea.prefab"],"Version":"1.0.0","Size":"3084","MD5":"6d5e266fe11b0fc0c01e5cd04f6f3308","Package":"","Updated":""},"xiaochong":{"AbName":"prefabs/xiaochong","AssetPath":["assets/assetbundles/prefabs/xiaochong.prefab"],"Version":"1.0.0","Size":"19479","MD5":"1b4930c9d61ce5be9398c7e77d4c58a9","Package":"","Updated":""},"00023-3589759801":{"AbName":"textures/00023-3589759801","AssetPath":["assets/assetbundles/textures/00023-3589759801.png"],"Version":"1.0.0","Size":"48503","MD5":"12c0064ab5941707445888ff526af03d","Package":"","Updated":""},"00029-3980031510":{"AbName":"textures/00029-3980031510","AssetPath":["assets/assetbundles/textures/00029-3980031510.png"],"Version":"1.0.0","Size":"109895","MD5":"57387b1e050648c91b9648734e8aa729","Package":"","Updated":""},"00031-1829375853":{"AbName":"textures/00031-1829375853","AssetPath":["assets/assetbundles/textures/00031-1829375853.png"],"Version":"1.0.0","Size":"228220","MD5":"f3d8d16cce2b896fb29b186a21bfdbd3","Package":"","Updated":""},"zishuzi_3":{"AbName":"textures/zishuzi_3","AssetPath":["assets/assetbundles/textures/zishuzi_3.png"],"Version":"1.0.0","Size":"5408","MD5":"4d340f0d0be33eb3606d8b681a48a1f1","Package":"","Updated":""},"zishuzi_4":{"AbName":"textures/zishuzi_4","AssetPath":["assets/assetbundles/textures/zishuzi_4.png"],"Version":"1.0.0","Size":"5234","MD5":"3d803d76372e1cfb50f5ef91693bc936","Package":"","Updated":""},"sdfadasd":{"AbName":"ui/sdfadasd","AssetPath":["assets/assetbundles/ui/sdfadasd.unity"],"Version":"1.0.0","Size":"50502","MD5":"21cf8a6727731d8a5a26e16d5799d561","Package":"","Updated":""},"UIPanel":{"AbName":"ui/uipanel","AssetPath":["assets/assetbundles/ui/uipanel.prefab"],"Version":"1.0.0","Size":"659458","MD5":"234b186e649a7947dcd976c39512fc6f","Package":"","Updated":""},"LocalizedStrings":{"AbName":"config/binconfigdata/localizedstrings","AssetPath":["assets/assetbundles/config/binconfigdata/localizedstrings.bytes"],"Version":"1.0.0","Size":"4463","MD5":"dbb0a53bfc93cf122044162906a222c2","Package":"","Updated":""},"Sheet1":{"AbName":"config/binconfigdata/sheet1","AssetPath":["assets/assetbundles/config/binconfigdata/sheet1.bytes"],"Version":"1.0.0","Size":"1873","MD5":"825a2478b5167c75ba1e4d30a9136471","Package":"","Updated":""},"Sheet2":{"AbName":"config/binconfigdata/sheet2","AssetPath":["assets/assetbundles/config/binconfigdata/sheet2.bytes"],"Version":"1.0.0","Size":"1943","MD5":"3e4ecedee812012815e392eccc330991","Package":"","Updated":""},"Cube1fsdf":{"AbName":"prefabs/pf2/aqq","AssetPath":["assets/assetbundles/prefabs/pf2/cube1fsdf.prefab"],"Version":"1.0.0","Size":"3731","MD5":"78d16003e941a13c17ad3db70458cb8e","Package":"","Updated":""},"Cube2sdfwe":{"AbName":"prefabs/pf2/cube2sdfwe","AssetPath":["assets/assetbundles/prefabs/pf2/cube2sdfwe.prefab"],"Version":"1.0.0","Size":"46022","MD5":"49ab6481a11fc6aba6d30899808ef275","Package":"","Updated":""},"Cubeljk":{"AbName":"prefabs/pf2/aqq","AssetPath":["assets/assetbundles/prefabs/pf2/cubeljk.prefab"],"Version":"1.0.0","Size":"3731","MD5":"78d16003e941a13c17ad3db70458cb8e","Package":"","Updated":""},"Audio":{"AbName":"","AssetPath":["2852","button1","\u3010Unity\u6846\u67B6\u3011\uFF0810\uFF09\u6E38\u620F\u5BF9\u8C61\u6C60","\u5927\u98CE-WQ20070525","\u5927\u98CE-WQ20070525_222","\u7B1B\u5B501-mcx20070508"],"Version":"1.0.0","Size":"","MD5":"","Package":"","Updated":""},"Code":{"AbName":"","AssetPath":["F8Framework.F8ExcelDataClass"],"Version":"1.0.0","Size":"","MD5":"","Package":"","Updated":""},"Config":{"AbName":"","AssetPath":[],"Version":"1.0.0","Size":"","MD5":"","Package":"","Updated":""},"Materials":{"AbName":"","AssetPath":["00029-3980031510mat","00031-1829375853mat","New Material"],"Version":"1.0.0","Size":"","MD5":"","Package":"","Updated":""},"Package_0":{"AbName":"","AssetPath":["uibg"],"Version":"1.0.0","Size":"","MD5":"","Package":"","Updated":""},"Package_1":{"AbName":"","AssetPath":["uibg 1"],"Version":"1.0.0","Size":"","MD5":"","Package":"","Updated":""},"Prefabs":{"AbName":"","AssetPath":["Cube","Cube1","Cube2","Pools","PoolsPreset","SphereA","xiaochong"],"Version":"1.0.0","Size":"","MD5":"","Package":"","Updated":""},"Textures":{"AbName":"","AssetPath":["00023-3589759801","00029-3980031510","00031-1829375853","zishuzi_3","zishuzi_4"],"Version":"1.0.0","Size":"","MD5":"","Package":"","Updated":""},"UI":{"AbName":"","AssetPath":["sdfadasd","UIPanel"],"Version":"1.0.0","Size":"","MD5":"","Package":"","Updated":""},"BinConfigData":{"AbName":"","AssetPath":["LocalizedStrings","Sheet1","Sheet2"],"Version":"1.0.0","Size":"","MD5":"","Package":"","Updated":""},"pf2":{"AbName":"","AssetPath":["Cube1fsdf","Cube2sdfwe","Cubeljk"],"Version":"1.0.0","Size":"","MD5":"","Package":"","Updated":""},"Windows":{"AbName":"Windows","AssetPath":[],"Version":"1.0.0","Size":"2743","MD5":"e80329693d1c6cb7d3cc9f9fd4691442","Package":"","Updated":""}} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index e440c79..65a66e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## [1.0.57] - 2024-11-06 +1.#18 本地化模块不再依赖资产,可使用id索引资产。如添加多张图片,改为只需要一个id +2.修复资产模块展开资源时类型错误的问题 + ## [1.0.56] - 2024-11-04 1.优化资产模块,编辑器模式下增加缓存,加快搜索速度 diff --git a/Editor/Localization/AudioLocalizerInspector.cs b/Editor/Localization/AudioLocalizerInspector.cs index 732f86d..80def2e 100644 --- a/Editor/Localization/AudioLocalizerInspector.cs +++ b/Editor/Localization/AudioLocalizerInspector.cs @@ -1,4 +1,6 @@ -using UnityEditor; +using System.Collections.Generic; +using System.Linq; +using UnityEditor; using UnityEngine; namespace F8Framework.Core.Editor @@ -7,12 +9,14 @@ namespace F8Framework.Core.Editor public class AudioLocalizerInspector : UnityEditor.Editor { AudioLocalizer localizer; + SerializedProperty localizedTextID; SerializedProperty playFromSamePositionWhenInject; void OnEnable() { localizer = (AudioLocalizer)target; playFromSamePositionWhenInject = serializedObject.FindProperty("playFromSamePositionWhenInject"); + localizedTextID = serializedObject.FindProperty("localizedTextID"); } public override void OnInspectorGUI() @@ -22,10 +26,82 @@ public override void OnInspectorGUI() Localization.Instance.LoadInEditor(); serializedObject.Update(); - EditorGUILayout.PropertyField(playFromSamePositionWhenInject, new GUIContent("从同一位置播放")); - var langCount = Localization.Instance.LanguageList.Count; + UpdateAudioClipInspector(langCount); + + serializedObject.ApplyModifiedProperties(); + + GUI.skin.GetStyle("HelpBox").richText = true; + Localization.Instance.LoadInEditor(); + var keys = Localization.Instance.GetAllIds(); + + if (keys.Count == 0) + { + EditorGUILayout.HelpBox("没有可用的数据。\n请将本地化表放在Excel存放文件夹中。", MessageType.Info); + return; + } + + if (string.IsNullOrEmpty(localizer.localizedTextID)) + { + EditorGUILayout.HelpBox($"输入 Text ID 或 拖拽音频 到上方", MessageType.Info); + + var postfix = keys.Count > 5 ? $"\n\n还有更多(共 {keys.Count.ToString()} 个ID)" : ""; + ShowSuggestion(keys.ToList(), postfix); + return; + } + + var dict = Localization.Instance.GetDictionaryFromId(localizer.localizedTextID); + if (dict != null) + { + var helpText = dict.Aggregate("", (current, item) => current + $"{item.Key}: {item.Value}\n"); + helpText = helpText.TrimEnd('\n'); + EditorGUILayout.HelpBox($"{helpText}", MessageType.Info); + } + else + { + EditorGUILayout.HelpBox($"Text ID:{localizer.localizedTextID} 不可用。", MessageType.Error); + } + + var suggestions = keys.Where(key => key.StartsWith(localizer.localizedTextID)).ToList(); + ShowSuggestion(suggestions); + } + + void ShowSuggestion(IReadOnlyCollection suggestions, string postfix = "") + { + var noSuggestion = suggestions.Count == 0; + var exactMatch = suggestions.Count == 1 && suggestions.First() == localizer.localizedTextID; + if (noSuggestion || exactMatch) return; + + var limit = LocalizationEditorSettings.current.maxSuggestion; + var text = suggestions.Take(limit) + .Aggregate("\nID 索引\n", (current, item) => $"{current}\n- {GetMarkedIdRepresentation(item)}"); + text += string.IsNullOrEmpty(postfix) ? "" : postfix; + EditorGUILayout.HelpBox($"{text}\n", MessageType.Info); + + string GetMarkedIdRepresentation(string id) + { + if (string.IsNullOrEmpty(localizer.localizedTextID)) + { + return id; + } + else + { + return $"{id.Insert(localizer.localizedTextID.Length, "")}"; + } + } + } + + void UpdateAudioClipInspector(int langCount) + { + EditorGUILayout.PropertyField(localizedTextID); + EditorGUILayout.PropertyField(playFromSamePositionWhenInject, new GUIContent("从同一位置播放")); + + if (!localizedTextID.stringValue.IsNullOrEmpty()) + { + return; + } + if (localizer.clips == null) { localizer.clips = new AudioClip[langCount]; @@ -49,8 +125,6 @@ public override void OnInspectorGUI() EditorUtility.SetDirty(localizer); } } - - serializedObject.ApplyModifiedProperties(); } } } diff --git a/Editor/Localization/ImageLocalizerInspector.cs b/Editor/Localization/ImageLocalizerInspector.cs index 2f96160..8ad45de 100644 --- a/Editor/Localization/ImageLocalizerInspector.cs +++ b/Editor/Localization/ImageLocalizerInspector.cs @@ -1,4 +1,6 @@ -using UnityEditor; +using System.Collections.Generic; +using System.Linq; +using UnityEditor; using UnityEngine; using UnityEngine.UI; @@ -8,12 +10,14 @@ namespace F8Framework.Core.Editor public class ImageLocalizerInspector : UnityEditor.Editor { ImageLocalizer localizer; + SerializedProperty localizedTextID; SerializedProperty propertyName; void OnEnable() { localizer = (ImageLocalizer)target; propertyName = serializedObject.FindProperty("propertyName"); + localizedTextID = serializedObject.FindProperty("localizedTextID"); } public override void OnInspectorGUI() @@ -45,12 +49,77 @@ public override void OnInspectorGUI() } serializedObject.ApplyModifiedProperties(); + + GUI.skin.GetStyle("HelpBox").richText = true; + Localization.Instance.LoadInEditor(); + var keys = Localization.Instance.GetAllIds(); + + if (keys.Count == 0) + { + EditorGUILayout.HelpBox("没有可用的数据。\n请将本地化表放在Excel存放文件夹中。", MessageType.Info); + return; + } + + if (string.IsNullOrEmpty(localizer.localizedTextID)) + { + EditorGUILayout.HelpBox($"输入 Text ID 或 拖拽图片 到上方", MessageType.Info); + + var postfix = keys.Count > 5 ? $"\n\n还有更多(共 {keys.Count.ToString()} 个ID)" : ""; + ShowSuggestion(keys.ToList(), postfix); + return; + } + + var dict = Localization.Instance.GetDictionaryFromId(localizer.localizedTextID); + if (dict != null) + { + var helpText = dict.Aggregate("", (current, item) => current + $"{item.Key}: {item.Value}\n"); + helpText = helpText.TrimEnd('\n'); + EditorGUILayout.HelpBox($"{helpText}", MessageType.Info); + } + else + { + EditorGUILayout.HelpBox($"Text ID:{localizer.localizedTextID} 不可用。", MessageType.Error); + } + + var suggestions = keys.Where(key => key.StartsWith(localizer.localizedTextID)).ToList(); + ShowSuggestion(suggestions); } + void ShowSuggestion(IReadOnlyCollection suggestions, string postfix = "") + { + var noSuggestion = suggestions.Count == 0; + var exactMatch = suggestions.Count == 1 && suggestions.First() == localizer.localizedTextID; + if (noSuggestion || exactMatch) return; + + var limit = LocalizationEditorSettings.current.maxSuggestion; + var text = suggestions.Take(limit) + .Aggregate("\nID 索引\n", (current, item) => $"{current}\n- {GetMarkedIdRepresentation(item)}"); + text += string.IsNullOrEmpty(postfix) ? "" : postfix; + EditorGUILayout.HelpBox($"{text}\n", MessageType.Info); + + string GetMarkedIdRepresentation(string id) + { + if (string.IsNullOrEmpty(localizer.localizedTextID)) + { + return id; + } + else + { + return $"{id.Insert(localizer.localizedTextID.Length, "")}"; + } + } + } + void UpdateTexture2DInspector(int langCount) { + EditorGUILayout.PropertyField(localizedTextID); EditorGUILayout.PropertyField(propertyName); - + + if (!localizedTextID.stringValue.IsNullOrEmpty()) + { + return; + } + if (localizer.texture2Ds == null) { localizer.texture2Ds = new Texture2D[langCount]; @@ -78,6 +147,13 @@ void UpdateTexture2DInspector(int langCount) void UpdateTextureInspector(int langCount) { + EditorGUILayout.PropertyField(localizedTextID); + + if (!localizedTextID.stringValue.IsNullOrEmpty()) + { + return; + } + if (localizer.textures == null) { localizer.textures = new Texture[langCount]; @@ -105,6 +181,13 @@ void UpdateTextureInspector(int langCount) void UpdateSpriteInspector(int langCount) { + EditorGUILayout.PropertyField(localizedTextID); + + if (!localizedTextID.stringValue.IsNullOrEmpty()) + { + return; + } + if (localizer.sprites == null) { localizer.sprites = new Sprite[langCount]; diff --git a/Editor/Localization/TextLocalizerInspector.cs b/Editor/Localization/TextLocalizerInspector.cs index 820e888..4285a07 100644 --- a/Editor/Localization/TextLocalizerInspector.cs +++ b/Editor/Localization/TextLocalizerInspector.cs @@ -25,7 +25,7 @@ public override void OnInspectorGUI() if (keys.Count == 0) { - EditorGUILayout.HelpBox("没有可用的数据。\n请将LocalizedStrings.tsv放在StreamingAssets/localization文件夹中。", MessageType.Info); + EditorGUILayout.HelpBox("没有可用的数据。\n请将本地化表放在Excel存放文件夹中。", MessageType.Info); return; } diff --git a/Editor/Localization/TextLocalizerPlayableAssetInspector.cs b/Editor/Localization/TextLocalizerPlayableAssetInspector.cs index 1138cd9..29bebbd 100644 --- a/Editor/Localization/TextLocalizerPlayableAssetInspector.cs +++ b/Editor/Localization/TextLocalizerPlayableAssetInspector.cs @@ -25,7 +25,7 @@ public override void OnInspectorGUI() if (keys.Count == 0) { - EditorGUILayout.HelpBox("没有可用的数据。\n请将LocalizedStrings.tsv放在StreamingAssets/localization文件夹中。", MessageType.Info); + EditorGUILayout.HelpBox("没有可用的数据。\n请将本地化表放在Excel存放文件夹中。", MessageType.Info); return; } diff --git a/Runtime/AssetManager/AssetBundleManager/AssetBundleLoader.cs b/Runtime/AssetManager/AssetBundleManager/AssetBundleLoader.cs index 0b23b64..132ec40 100644 --- a/Runtime/AssetManager/AssetBundleManager/AssetBundleLoader.cs +++ b/Runtime/AssetManager/AssetBundleManager/AssetBundleLoader.cs @@ -228,7 +228,7 @@ public IEnumerator LoadAsyncCoroutine() /// 对于Unity中无法扩展的流场景资产包类型, /// 此扩展函数将忽略它,并直接将其标记为已展开。 /// - public virtual void Expand() + public virtual void Expand(System.Type type) { if (assetBundleContent == null) { @@ -244,9 +244,16 @@ public virtual void Expand() return; expandCount = 0; - foreach (string path in assetPaths) + for (int i = 0; i < assetPaths.Count; i++) { - LoadAssetObject(path); + if (i == assetPaths.Count - 1) + { + LoadAssetObject(assetPaths[i], type); + } + else + { + LoadAssetObject(assetPaths[i]); + } } expandCount = assetPaths.Count; @@ -259,7 +266,7 @@ public virtual void Expand() /// 对于无法在Unity中展开的流场景资产束类型, /// 此扩展函数将忽略它,并直接将其标记为已扩展。 /// - public virtual void ExpandAsync(OnExpandFinished callback = null) + public virtual void ExpandAsync(System.Type assetType, OnExpandFinished callback = null) { if (assetBundleContent == null) { @@ -277,9 +284,16 @@ public virtual void ExpandAsync(OnExpandFinished callback = null) { expandCount = 0; assetBundleExpandState = LoaderState.WORKING; - foreach (string path in assetPaths) + for (int i = 0; i < assetPaths.Count; i++) { - LoadAssetObjectAsync(path, OnOneExpandCallBack); + if (i == assetPaths.Count - 1) + { + LoadAssetObjectAsync(assetPaths[i], assetType, OnOneExpandCallBack); + } + else + { + LoadAssetObjectAsync(assetPaths[i], OnOneExpandCallBack); + } } } } @@ -290,7 +304,7 @@ public virtual void ExpandAsync(OnExpandFinished callback = null) /// 有机会assetBundle还未加载完,所以就没有展开。 /// /// - public IEnumerator ExpandAsyncCoroutine() + public IEnumerator ExpandAsyncCoroutine(System.Type assetType) { if (assetBundleContent == null) { @@ -305,10 +319,16 @@ public IEnumerator ExpandAsyncCoroutine() { expandCount = 0; assetBundleExpandState = LoaderState.WORKING; - foreach (string path in assetPaths) + for (int i = 0; i < assetPaths.Count; i++) { - yield return LoadAssetObjectAsyncCoroutine(path); + Util.Unity.StartCoroutine(LoadAssetObjectAsyncCoroutine(assetPaths[i], + i == assetPaths.Count - 1 ? assetType : default)); } + yield return new WaitUntil(() => ExpandProgress >= 1f); + } + else if (assetBundleExpandState == LoaderState.WORKING) + { + yield return new WaitUntil(() => ExpandProgress >= 1f); } } @@ -412,15 +432,24 @@ public Object LoadAssetObject(string assetPath, System.Type assetType) if (assetBundleContent.isStreamedSceneAssetBundle) return null; - Object o = assetBundleContent.LoadAsset(assetPath, assetType); + Object o = assetType == default ? + assetBundleContent.LoadAsset(assetPath) : + assetBundleContent.LoadAsset(assetPath, assetType); SetAssetObject(assetPath, o); - if (assetType.IsAssignableFrom(o.GetType())) + if (assetType == default) { return o; } else { - return null; + if (assetType.IsAssignableFrom(o.GetType())) + { + return o; + } + else + { + return null; + } } } @@ -502,19 +531,28 @@ public void LoadAssetObjectAsync( return; } - AssetBundleRequest rq = assetBundleContent.LoadAssetAsync(assetPath, assetType); + AssetBundleRequest rq = assetType == default ? + assetBundleContent.LoadAssetAsync(assetPath) : + assetBundleContent.LoadAssetAsync(assetPath, assetType); rq.completed += ao => { Object o = rq.asset; SetAssetObject(assetPath, o); - if (assetType.IsAssignableFrom(o.GetType())) + if (assetType == default) { End(o); } else { - End(); + if (assetType.IsAssignableFrom(o.GetType())) + { + End(o); + } + else + { + End(); + } } }; @@ -558,7 +596,7 @@ void End(Object o = null) } } - public IEnumerator LoadAssetObjectAsyncCoroutine(string assetPath) + public IEnumerator LoadAssetObjectAsyncCoroutine(string assetPath, System.Type assetType) { // 流化场景资产包不需要扩展, // 但必须通过UnityEngine进行访问。场景管理。场景管理器。 @@ -567,11 +605,14 @@ public IEnumerator LoadAssetObjectAsyncCoroutine(string assetPath) yield break; } - AssetBundleRequest rq = assetBundleContent.LoadAssetAsync(assetPath); + AssetBundleRequest rq = assetType == default ? + assetBundleContent.LoadAssetAsync(assetPath) : + assetBundleContent.LoadAssetAsync(assetPath, assetType); yield return rq; Object o = rq.asset; SetAssetObject(assetPath, o); + ++expandCount; } /// @@ -983,7 +1024,7 @@ public float LoadProgress } /// - /// 扩大进度。 + /// 展开进度。 /// 值的范围从0到1。 /// public float ExpandProgress diff --git a/Runtime/AssetManager/AssetBundleManager/AssetBundleManager.cs b/Runtime/AssetManager/AssetBundleManager/AssetBundleManager.cs index ed40347..1e8a902 100644 --- a/Runtime/AssetManager/AssetBundleManager/AssetBundleManager.cs +++ b/Runtime/AssetManager/AssetBundleManager/AssetBundleManager.cs @@ -21,9 +21,10 @@ public class AssetBundleManager : ModuleSingleton, IModule /// 如果重复加载资产,则将直接从资源池中提供。 /// /// 资产名称。 + /// 资产类型。 /// 资产信息。 /// 要完成扩展的对象列表。 - public AssetBundle Load(string assetName, ref AssetManager.AssetInfo info) + public AssetBundle Load(string assetName, System.Type assetType, ref AssetManager.AssetInfo info) { AssetBundle result; @@ -64,7 +65,7 @@ public AssetBundle Load(string assetName, ref AssetManager.AssetInfo info) ++loadedCount; if (loadedCount == assetBundlePaths.Count) { - loader.Expand(); + loader.Expand(assetType); } } @@ -77,10 +78,12 @@ public AssetBundle Load(string assetName, ref AssetManager.AssetInfo info) /// 如果重复加载资产,则将直接从资源池中提供。 /// /// 资产名称。 + /// 资产类型。 /// 资产信息。 /// 异步加载完成的回调。 public void LoadAsync( string assetName, + System.Type assetType, AssetManager.AssetInfo info, AssetBundleLoader.OnLoadFinished loadCallback = null) { @@ -124,7 +127,7 @@ public void LoadAsync( if (loadedCount == assetBundlePaths.Count) { // 所有依赖项加载完成后,加载主资源 - lastLoader.ExpandAsync(() => + lastLoader.ExpandAsync(assetType, () => { // 主资源加载完成后,如果需要展开,则在展开完成后回调 loadCallback?.Invoke(GetAssetBundle(info.AssetBundlePath)); @@ -135,7 +138,7 @@ public void LoadAsync( } } - public IEnumerator LoadAsyncCoroutine(string assetName, AssetManager.AssetInfo info) + public IEnumerator LoadAsyncCoroutine(string assetName, System.Type assetType, AssetManager.AssetInfo info) { List assetBundlePaths = new List(GetDependenciedAssetBundles(info.AbName)); @@ -176,7 +179,7 @@ public IEnumerator LoadAsyncCoroutine(string assetName, AssetManager.AssetInfo i if (loadedCount == assetBundlePaths.Count) { // 所有依赖项加载完成后,加载主资源 - yield return lastLoader.ExpandAsyncCoroutine(); + yield return lastLoader.ExpandAsyncCoroutine(assetType); yield break; } } diff --git a/Runtime/AssetManager/AssetManager.cs b/Runtime/AssetManager/AssetManager.cs index b0525be..4e0b683 100644 --- a/Runtime/AssetManager/AssetManager.cs +++ b/Runtime/AssetManager/AssetManager.cs @@ -214,7 +214,7 @@ public T GetAssetObject( return o; } AssetBundleLoader ab = AssetBundleManager.Instance.GetAssetBundleLoader(info.AssetBundlePath); - ab.Expand(); + ab.Expand(typeof(T)); o = AssetBundleManager.Instance.GetAssetObject(info.AssetBundlePath, info.AssetPath[0]); if (o != null) { @@ -266,7 +266,7 @@ public Object GetAssetObject( return o; } AssetBundleLoader ab = AssetBundleManager.Instance.GetAssetBundleLoader(info.AssetBundlePath); - ab.Expand(); + ab.Expand(assetType); o = AssetBundleManager.Instance.GetAssetObject(info.AssetBundlePath, info.AssetPath[0], assetType); if (o != null) { @@ -316,7 +316,7 @@ public Object GetAssetObject( return o; } AssetBundleLoader ab = AssetBundleManager.Instance.GetAssetBundleLoader(info.AssetBundlePath); - ab.Expand(); + ab.Expand(default); o = AssetBundleManager.Instance.GetAssetObject(info.AssetBundlePath, info.AssetPath[0]); if (o != null) { @@ -374,7 +374,7 @@ public T Load( if (ab == null || ab.AssetBundleContent == null) { - AssetBundleManager.Instance.Load(assetName, ref info); + AssetBundleManager.Instance.Load(assetName, typeof(T), ref info); ab = AssetBundleManager.Instance.GetAssetBundleLoader(info.AssetBundlePath); } @@ -384,7 +384,7 @@ public T Load( return o; } - ab.Expand(); + ab.Expand(typeof(T)); return AssetBundleManager.Instance.GetAssetObject(info.AssetBundlePath, info.AssetPath[0]); } @@ -426,7 +426,7 @@ public void LoadDir( AssetBundleLoader ab = AssetBundleManager.Instance.GetAssetBundleLoader(subInfo.AssetBundlePath); if (ab == null || ab.AssetBundleContent == null) { - AssetBundleManager.Instance.Load(subAssetName, ref subInfo); + AssetBundleManager.Instance.Load(subAssetName, default, ref subInfo); } } } @@ -477,7 +477,7 @@ public Object Load( if (ab == null || ab.AssetBundleContent == null) { - AssetBundleManager.Instance.Load(assetName, ref info); + AssetBundleManager.Instance.Load(assetName, assetType, ref info); ab = AssetBundleManager.Instance.GetAssetBundleLoader(info.AssetBundlePath); } @@ -487,7 +487,7 @@ public Object Load( return o; } - ab.Expand(); + ab.Expand(assetType); return AssetBundleManager.Instance.GetAssetObject(info.AssetBundlePath, info.AssetPath[0], assetType); } @@ -537,7 +537,7 @@ public Object Load( if (ab == null || ab.AssetBundleContent == null) { - AssetBundleManager.Instance.Load(assetName, ref info); + AssetBundleManager.Instance.Load(assetName, default, ref info); ab = AssetBundleManager.Instance.GetAssetBundleLoader(info.AssetBundlePath); } @@ -546,7 +546,7 @@ public Object Load( { return o; } - ab.Expand(); + ab.Expand(default); return AssetBundleManager.Instance.GetAssetObject(info.AssetBundlePath, info.AssetPath[0]); } @@ -603,7 +603,7 @@ public void LoadAsync( AssetBundleLoader ab = AssetBundleManager.Instance.GetAssetBundleLoader(info.AssetBundlePath); if (ab == null || ab.AssetBundleContent == null || ab.GetDependentNamesLoadFinished() < ab.AddDependentNames()) { - AssetBundleManager.Instance.LoadAsync(assetName, info, (b) => { + AssetBundleManager.Instance.LoadAsync(assetName, typeof(T), info, (b) => { End(AssetBundleManager.Instance.GetAssetObject(info.AssetBundlePath, info.AssetPath[0])); }); return; @@ -617,7 +617,7 @@ public void LoadAsync( return; } - ab.Expand(); + ab.Expand(typeof(T)); End(AssetBundleManager.Instance.GetAssetObject(info.AssetBundlePath, info.AssetPath[0])); } } @@ -674,7 +674,7 @@ public IEnumerator LoadAsyncCoroutine(string assetName, AssetAccessMode mode AssetBundleLoader ab = AssetBundleManager.Instance.GetAssetBundleLoader(info.AssetBundlePath); if (ab == null || ab.AssetBundleContent == null || ab.GetDependentNamesLoadFinished() < ab.AddDependentNames()) { - yield return AssetBundleManager.Instance.LoadAsyncCoroutine(assetName, info); + yield return AssetBundleManager.Instance.LoadAsyncCoroutine(assetName, typeof(T), info); yield return AssetBundleManager.Instance.GetAssetObject(info.AssetBundlePath, info.AssetPath[0]); } else @@ -686,7 +686,7 @@ public IEnumerator LoadAsyncCoroutine(string assetName, AssetAccessMode mode } else { - ab.Expand(); + ab.Expand(typeof(T)); yield return AssetBundleManager.Instance.GetAssetObject(info.AssetBundlePath, info.AssetPath[0]); } } @@ -699,7 +699,7 @@ public IEnumerator LoadAsyncCoroutine(string assetName, AssetAccessMode mode /// 资产路径字符串。 /// 目标资产类型。 /// 访问模式。 - public IEnumerator LoadAsyncCoroutine(string assetName, System.Type assetType = default, AssetAccessMode mode = AssetAccessMode.UNKNOWN) + public IEnumerator LoadAsyncCoroutine(string assetName, System.Type assetType, AssetAccessMode mode = AssetAccessMode.UNKNOWN) { AssetInfo info = GetAssetInfo(assetName, mode); if (!IsLegal(ref info)) @@ -742,7 +742,7 @@ public IEnumerator LoadAsyncCoroutine(string assetName, System.Type assetType = AssetBundleLoader ab = AssetBundleManager.Instance.GetAssetBundleLoader(info.AssetBundlePath); if (ab == null || ab.AssetBundleContent == null || ab.GetDependentNamesLoadFinished() < ab.AddDependentNames()) { - yield return AssetBundleManager.Instance.LoadAsyncCoroutine(assetName, info); + yield return AssetBundleManager.Instance.LoadAsyncCoroutine(assetName, assetType, info); yield return AssetBundleManager.Instance.GetAssetObject(info.AssetBundlePath, info.AssetPath[0], assetType); } else @@ -754,7 +754,7 @@ public IEnumerator LoadAsyncCoroutine(string assetName, System.Type assetType = } else { - ab.Expand(); + ab.Expand(assetType); yield return AssetBundleManager.Instance.GetAssetObject(info.AssetBundlePath, info.AssetPath[0], assetType); } } @@ -804,7 +804,7 @@ public void LoadDirAsync( AssetBundleLoader ab = AssetBundleManager.Instance.GetAssetBundleLoader(subInfo.AssetBundlePath); if (ab == null || ab.AssetBundleContent == null || ab.GetDependentNamesLoadFinished() < ab.AddDependentNames()) { - AssetBundleManager.Instance.LoadAsync(subAssetName, + AssetBundleManager.Instance.LoadAsync(subAssetName, default, subInfo, (b) => { if (++assetCount >= info.AssetPath.Length) @@ -825,7 +825,7 @@ public void LoadDirAsync( continue; } - ab.Expand(); + ab.Expand(default); if (++assetCount >= info.AssetPath.Length) { End(); @@ -877,7 +877,7 @@ public IEnumerable LoadDirAsyncCoroutine(string assetName, AssetAccessMode mode AssetBundleLoader ab = AssetBundleManager.Instance.GetAssetBundleLoader(subInfo.AssetBundlePath); if (ab == null || ab.AssetBundleContent == null || ab.GetDependentNamesLoadFinished() < ab.AddDependentNames()) { - yield return AssetBundleManager.Instance.LoadAsyncCoroutine(subAssetName, subInfo); + yield return AssetBundleManager.Instance.LoadAsyncCoroutine(subAssetName, default, subInfo); if (++assetCount >= info.AssetPath.Length) { yield break; @@ -895,7 +895,7 @@ public IEnumerable LoadDirAsyncCoroutine(string assetName, AssetAccessMode mode continue; } - ab.Expand(); + ab.Expand(default); if (++assetCount >= info.AssetPath.Length) { yield break; @@ -956,7 +956,7 @@ public void LoadAsync( if (ab == null || ab.AssetBundleContent == null) { - AssetBundleManager.Instance.LoadAsync(assetName, info, (b) => { + AssetBundleManager.Instance.LoadAsync(assetName, assetType, info, (b) => { End(AssetBundleManager.Instance.GetAssetObject(info.AssetBundlePath, info.AssetPath[0], assetType)); }); return; @@ -970,7 +970,7 @@ public void LoadAsync( return; } - ab.Expand(); + ab.Expand(assetType); End(AssetBundleManager.Instance.GetAssetObject(info.AssetBundlePath, info.AssetPath[0], assetType)); } } @@ -1030,7 +1030,7 @@ public void LoadAsync( if (ab == null || ab.AssetBundleContent == null) { - AssetBundleManager.Instance.LoadAsync(assetName, info, (b) => { + AssetBundleManager.Instance.LoadAsync(assetName, default, info, (b) => { End(AssetBundleManager.Instance.GetAssetObject(info.AssetBundlePath, info.AssetPath[0])); }); return; @@ -1044,7 +1044,7 @@ public void LoadAsync( return; } - ab.Expand(); + ab.Expand(default); End(AssetBundleManager.Instance.GetAssetObject(info.AssetBundlePath, info.AssetPath[0])); } } diff --git a/Runtime/Localization/Audio/AudioLocalizer.cs b/Runtime/Localization/Audio/AudioLocalizer.cs index 51d22f2..5da3267 100644 --- a/Runtime/Localization/Audio/AudioLocalizer.cs +++ b/Runtime/Localization/Audio/AudioLocalizer.cs @@ -4,6 +4,7 @@ namespace F8Framework.Core { public class AudioLocalizer : LocalizerBase { + public string localizedTextID = ""; public AudioClip[] clips; public bool playFromSamePositionWhenInject; @@ -14,14 +15,46 @@ protected override void Prepare() if (component is AudioSource audio) { - injector = new AudioSourceInjector(audio); + injector = new AudioSourceInjector(audio, localizedTextID); } } internal override void Localize() { + ChangeID(localizedTextID); var index = Localization.Instance.CurrentLanguageIndex; injector.Inject(clips[index], this); } + + public bool ChangeID(string textId) + { + if (string.IsNullOrEmpty(textId)) return false; + +#if UNITY_EDITOR + // for Timeline Preview + if (!Application.isPlaying) + { + Localization.Instance.Load(); + Prepare(); + } +#endif + + if (!Localization.Instance.Has(textId)) + { + if (Application.isPlaying) LogF8.LogError($"Text ID: {textId} 不可用。"); + return false; + } + + this.localizedTextID = textId; + var text = Localization.Instance.GetTextFromId(textId); + injector.Inject(text, this); + return true; + } + + public void Clear() + { + localizedTextID = null; + injector.Inject("", this); + } } } diff --git a/Runtime/Localization/Audio/AudioSourceInjector.cs b/Runtime/Localization/Audio/AudioSourceInjector.cs index 0178dfa..e8955a0 100644 --- a/Runtime/Localization/Audio/AudioSourceInjector.cs +++ b/Runtime/Localization/Audio/AudioSourceInjector.cs @@ -4,10 +4,12 @@ namespace F8Framework.Core { public class AudioSourceInjector : IInjector { + readonly string localizedTextID; readonly AudioSource audio; - public AudioSourceInjector(AudioSource audio) + public AudioSourceInjector(AudioSource audio, string localizedTextID) { + this.localizedTextID = localizedTextID; this.audio = audio; } @@ -18,17 +20,33 @@ public void Inject(T1 localizedData, T2 localizer) where T2 : LocalizerB if (isPlaying) audio.Stop(); var playFromSamePosition = (localizer as AudioLocalizer)?.playFromSamePositionWhenInject; - audio.clip = localizedData as AudioClip; - if (isPlaying) + if (localizedTextID.IsNullOrEmpty()) { - audio.Play(); - if (playFromSamePosition.HasValue && playFromSamePosition.Value) + Play(localizedData as AudioClip); + } + else + { + string textIDValue = Localization.Instance.GetTextFromId(localizedTextID); + AssetManager.Instance.LoadAsync(textIDValue, (asset) => { - audio.time = time; - } - else + Play(asset); + }); + } + + void Play(AudioClip audioClip) + { + audio.clip = audioClip; + if (isPlaying) { - audio.time = 0f; + audio.Play(); + if (playFromSamePosition.HasValue && playFromSamePosition.Value) + { + audio.time = time; + } + else + { + audio.time = 0f; + } } } } diff --git a/Runtime/Localization/Image/ImageLocalizer.cs b/Runtime/Localization/Image/ImageLocalizer.cs index 65524fb..1503ce5 100644 --- a/Runtime/Localization/Image/ImageLocalizer.cs +++ b/Runtime/Localization/Image/ImageLocalizer.cs @@ -5,11 +5,12 @@ namespace F8Framework.Core { public class ImageLocalizer : LocalizerBase { + public string localizedTextID = ""; public string propertyName = "_MainTex"; public Texture2D[] texture2Ds; public Sprite[] sprites; public Texture[] textures; - + protected override void Prepare() { var component = ComponentFinder.Find(this); @@ -17,26 +18,58 @@ protected override void Prepare() if (component is Image image) { - injector = new UIImageInjector(image, sprites); + injector = new UIImageInjector(image, localizedTextID, sprites); } else if (component is RawImage rawImage) { - injector = new RawImageInjector(rawImage, textures); + injector = new RawImageInjector(rawImage, localizedTextID, textures); } else if (component is SpriteRenderer spriteRenderer) { - injector = new SpriteRendererInjector(spriteRenderer, sprites); + injector = new SpriteRendererInjector(spriteRenderer, localizedTextID, sprites); } else if (component is Renderer renderer) { - injector = new TextureInjector(renderer, propertyName, texture2Ds); + injector = new TextureInjector(renderer, localizedTextID, propertyName, texture2Ds); } } internal override void Localize() { + ChangeID(localizedTextID); var index = Localization.Instance.CurrentLanguageIndex; injector.Inject(index, this); } + + public bool ChangeID(string textId) + { + if (string.IsNullOrEmpty(textId)) return false; + +#if UNITY_EDITOR + // for Timeline Preview + if (!Application.isPlaying) + { + Localization.Instance.Load(); + Prepare(); + } +#endif + + if (!Localization.Instance.Has(textId)) + { + if (Application.isPlaying) LogF8.LogError($"Text ID: {textId} 不可用。"); + return false; + } + + this.localizedTextID = textId; + var text = Localization.Instance.GetTextFromId(textId); + injector.Inject(text, this); + return true; + } + + public void Clear() + { + localizedTextID = null; + injector.Inject("", this); + } } } diff --git a/Runtime/Localization/Image/RawImageInjector.cs b/Runtime/Localization/Image/RawImageInjector.cs index f8d7964..a566320 100644 --- a/Runtime/Localization/Image/RawImageInjector.cs +++ b/Runtime/Localization/Image/RawImageInjector.cs @@ -5,11 +5,13 @@ namespace F8Framework.Core { public class RawImageInjector : IInjector { + readonly string localizedTextID; readonly RawImage rawImage; readonly Texture[] textures; - public RawImageInjector(RawImage rawImage, Texture[] textures) + public RawImageInjector(RawImage rawImage, string localizedTextID, Texture[] textures) { + this.localizedTextID = localizedTextID; this.rawImage = rawImage; this.textures = textures; } @@ -18,7 +20,25 @@ public void Inject(T1 localizedData, T2 localizer) where T2 : LocalizerB { if (localizedData is int index) { - rawImage.texture = textures[index]; + if (localizedTextID.IsNullOrEmpty()) + { + rawImage.texture = textures[index]; + } + else + { + string textIDValue = Localization.Instance.GetTextFromId(localizedTextID); + AssetManager.Instance.LoadAsync(textIDValue, (asset) => + { + if (asset is Sprite sprite) + { + Texture texture = sprite.texture; + rawImage.texture = texture; + LogF8.LogAsset("本地化图片类型错误,已自动转换:" + asset); + return; + } + rawImage.texture = asset as Texture; + }); + } } } } diff --git a/Runtime/Localization/Image/SpriteRendererInjector.cs b/Runtime/Localization/Image/SpriteRendererInjector.cs index 2a51f3f..30ea23f 100644 --- a/Runtime/Localization/Image/SpriteRendererInjector.cs +++ b/Runtime/Localization/Image/SpriteRendererInjector.cs @@ -4,11 +4,13 @@ namespace F8Framework.Core { public class SpriteRendererInjector : IInjector { + readonly string localizedTextID; readonly SpriteRenderer spriteRenderer; readonly Sprite[] sprites; - public SpriteRendererInjector(SpriteRenderer spriteRenderer, Sprite[] sprites) + public SpriteRendererInjector(SpriteRenderer spriteRenderer, string localizedTextID, Sprite[] sprites) { + this.localizedTextID = localizedTextID; this.spriteRenderer = spriteRenderer; this.sprites = sprites; } @@ -17,7 +19,25 @@ public void Inject(T1 localizedData, T2 localizer) where T2 : LocalizerB { if (localizedData is int index) { - spriteRenderer.sprite = sprites[index]; + if (localizedTextID.IsNullOrEmpty()) + { + spriteRenderer.sprite = sprites[index]; + } + else + { + string textIDValue = Localization.Instance.GetTextFromId(localizedTextID); + AssetManager.Instance.LoadAsync(textIDValue, (asset) => + { + if (asset is Texture2D texture) + { + Sprite sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f)); + spriteRenderer.sprite = sprite; + LogF8.LogAsset("本地化图片类型错误,已自动转换:" + asset); + return; + } + spriteRenderer.sprite = asset as Sprite; + }); + } } } } diff --git a/Runtime/Localization/Image/TextureInjector.cs b/Runtime/Localization/Image/TextureInjector.cs index 6a346cc..e83fd54 100644 --- a/Runtime/Localization/Image/TextureInjector.cs +++ b/Runtime/Localization/Image/TextureInjector.cs @@ -4,12 +4,14 @@ namespace F8Framework.Core { public class TextureInjector : IInjector { + readonly string localizedTextID; readonly Renderer renderer; readonly string propertyName; readonly Texture2D[] texture2Ds; - public TextureInjector(Renderer renderer, string propertyName, Texture2D[] texture2Ds) + public TextureInjector(Renderer renderer, string localizedTextID, string propertyName, Texture2D[] texture2Ds) { + this.localizedTextID = localizedTextID; this.renderer = renderer; this.propertyName = propertyName; this.texture2Ds = texture2Ds; @@ -19,7 +21,25 @@ public void Inject(T1 localizedData, T2 localizer) where T2 : LocalizerB { if (localizedData is int index) { - renderer.material.SetTexture(propertyName, texture2Ds[index]); + if (localizedTextID.IsNullOrEmpty()) + { + renderer.material.SetTexture(propertyName, texture2Ds[index]); + } + else + { + string textIDValue = Localization.Instance.GetTextFromId(localizedTextID); + AssetManager.Instance.LoadAsync(textIDValue, (asset) => + { + if (asset is Sprite sprite) + { + Texture2D texture = sprite.texture; + renderer.material.SetTexture(propertyName, texture); + LogF8.LogAsset("本地化图片类型错误,已自动转换:" + asset); + return; + } + renderer.material.SetTexture(propertyName, asset as Texture2D); + }); + } } } } diff --git a/Runtime/Localization/Image/UIImageInjector.cs b/Runtime/Localization/Image/UIImageInjector.cs index 9575271..ff2ed0f 100644 --- a/Runtime/Localization/Image/UIImageInjector.cs +++ b/Runtime/Localization/Image/UIImageInjector.cs @@ -5,11 +5,13 @@ namespace F8Framework.Core { public class UIImageInjector : IInjector { + readonly string localizedTextID; readonly Image image; readonly Sprite[] sprites; - public UIImageInjector(Image image, Sprite[] sprites) + public UIImageInjector(Image image, string localizedTextID, Sprite[] sprites) { + this.localizedTextID = localizedTextID; this.image = image; this.sprites = sprites; } @@ -18,7 +20,25 @@ public void Inject(T1 localizedData, T2 localizer) where T2 : LocalizerB { if (localizedData is int index) { - image.sprite = sprites[index]; + if (localizedTextID.IsNullOrEmpty()) + { + image.sprite = sprites[index]; + } + else + { + string textIDValue = Localization.Instance.GetTextFromId(localizedTextID); + AssetManager.Instance.LoadAsync(textIDValue, (asset) => + { + if (asset is Texture2D texture) + { + Sprite sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f)); + image.sprite = sprite; + LogF8.LogAsset("本地化图片类型错误,已自动转换:" + asset); + return; + } + image.sprite = asset as Sprite; + }); + } } } } diff --git a/Tests/GameObjectPool/DemoGameObjectPool.cs b/Tests/GameObjectPool/DemoGameObjectPool.cs index 84e0b62..2f6d124 100644 --- a/Tests/GameObjectPool/DemoGameObjectPool.cs +++ b/Tests/GameObjectPool/DemoGameObjectPool.cs @@ -23,7 +23,7 @@ void Start() // 使用名称或GameObject或者Component创建对象 GameObject spawnedClone = FF8.GameObjectPool.Spawn("name"); - GameObject spawnedClone = FF8.GameObjectPool.Spawn(_gameObjectPrefab); + spawnedClone = FF8.GameObjectPool.Spawn(_gameObjectPrefab); DemoGameObjectPool component = FF8.GameObjectPool.Spawn(_componentPrefab, Vector3.zero, Quaternion.identity, this.transform); @@ -37,7 +37,7 @@ void Start() // 如何获取对象池 F8GameObjectPool _pool = FF8.GameObjectPool.GetPoolByPrefab(_gameObjectPrefab); - F8GameObjectPool _pool = FF8.GameObjectPool.GetPoolByPrefabName(_gameObjectPrefab.name); + _pool = FF8.GameObjectPool.GetPoolByPrefabName(_gameObjectPrefab.name); // 对每个池执行操作。 FF8.GameObjectPool.ForEachPool(LogF8.Log); diff --git a/Tests/Network/SimpleWebTransport/ExampleWebClient.cs b/Tests/Network/SimpleWebTransport/ExampleWebClient.cs index 0dbc39f..4269719 100644 --- a/Tests/Network/SimpleWebTransport/ExampleWebClient.cs +++ b/Tests/Network/SimpleWebTransport/ExampleWebClient.cs @@ -1,6 +1,6 @@ using System; using F8Framework.Core; -using JamesFrowen.SimpleWeb; +using Mirror.SimpleWeb; using UnityEngine; namespace F8Framework.Tests diff --git a/Tests/Network/SimpleWebTransport/ExampleWebServer.cs b/Tests/Network/SimpleWebTransport/ExampleWebServer.cs index 4e25c50..52d86a1 100644 --- a/Tests/Network/SimpleWebTransport/ExampleWebServer.cs +++ b/Tests/Network/SimpleWebTransport/ExampleWebServer.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Security.Authentication; using F8Framework.Core; -using JamesFrowen.SimpleWeb; +using Mirror.SimpleWeb; using UnityEngine; namespace F8Framework.Tests @@ -38,7 +38,7 @@ private IEnumerator Start() SslConfig sslConfig = SslConfigLoader.Load(sslEnabled, sslCertJson, sslProtocols); server = new SimpleWebServer(_maxMessagePerTick, tcpConfig, _maxMessageSize, _maxHandShakeSize, sslConfig); - server.onConnect += (id) => { connection = true; LogF8.LogNet($"New Client connected, id:{id}"); }; + server.onConnect += (id, ip) => { connection = true; LogF8.LogNet($"New Client connected, id:{id}, ip:{ip}"); }; server.onDisconnect += (id) => LogF8.LogNet($"Client disconnected, id:{id}"); server.onData += OnData; server.onError += (id, exception) => LogF8.LogNet($"Error because of Client, id:{id}, Error:{exception}"); diff --git a/Tests/Tween/DemoTween.cs b/Tests/Tween/DemoTween.cs index 9915a25..08a258d 100644 --- a/Tests/Tween/DemoTween.cs +++ b/Tests/Tween/DemoTween.cs @@ -1,3 +1,5 @@ +using F8Framework.Core; +using F8Framework.Launcher; using UnityEngine; using UnityEngine.UI; diff --git a/package.json b/package.json index 4fa7e58..d18ce6d 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "com.tippinggame.f8framework", "displayName": "F8Framework", "description": "Unity F8Framework Core", - "version": "1.0.56", + "version": "1.0.57", "unity": "2021.3", "license": "MIT", "keywords": ["Unity", "Framework", "Core"],