diff --git a/AssetMap/Resources/AssetBundleMap.json b/AssetMap/Resources/AssetBundleMap.json index c562629..e31890c 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":"13b86da06a7db926e88afc306c3081a9","Package":"","Updated":""},"button1":{"AbName":"audio/button1","AssetPath":["assets/assetbundles/audio/button1.wav"],"Version":"1.0.0","Size":"15567","MD5":"a818c3ecef6f0dad489e3351a3a09485","Package":"","Updated":""},"\u5927\u98CE-WQ20070525":{"AbName":"audio/\u5927\u98CE-wq20070525","AssetPath":["assets/assetbundles/audio/\u5927\u98CE-wq20070525.mp3"],"Version":"1.0.0","Size":"559199","MD5":"0f826f53d47e04a0a5f095fe3814ea25","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":"eba3243db88378c73f230c78262c8425","Package":"","Updated":""},"HotUpdate":{"AbName":"code/hotupdate","AssetPath":["assets/assetbundles/code/hotupdate.bytes"],"Version":"1.0.0","Size":"4132","MD5":"0ad08eba0551c7341a0c416bc4527437","Package":"","Updated":""},"00029-3980031510mat":{"AbName":"materials/00029-3980031510mat","AssetPath":["assets/assetbundles/materials/00029-3980031510mat.mat"],"Version":"1.0.0","Size":"148099","MD5":"04c0074f0f84c290f51ea433fc33a70b","Package":"","Updated":""},"00031-1829375853mat":{"AbName":"materials/00031-1829375853mat","AssetPath":["assets/assetbundles/materials/00031-1829375853mat.mat"],"Version":"1.0.0","Size":"343362","MD5":"36711d5c4122c0a0d136f5e171532554","Package":"","Updated":""},"uibg":{"AbName":"package_0/uibg","AssetPath":["assets/assetbundles/package_0/uibg.mat"],"Version":"1.0.0","Size":"19073","MD5":"f26d78dd64848ba3974746e86d0f221d","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":"00668a40d64cf36bc99c455f6887822b","Package":"1","Updated":""},"Cube":{"AbName":"prefabs/pf2/cube2sdfwe","AssetPath":["assets/assetbundles/prefabs/cube.prefab"],"Version":"1.0.0","Size":"45910","MD5":"eb3bd9afd239cce91e12d0d78c7b05a7","Package":"","Updated":""},"Cube1":{"AbName":"prefabs/pf2/cube2sdfwe","AssetPath":["assets/assetbundles/prefabs/cube1.prefab"],"Version":"1.0.0","Size":"45910","MD5":"eb3bd9afd239cce91e12d0d78c7b05a7","Package":"","Updated":""},"Cube2":{"AbName":"prefabs/pf2/cube2sdfwe","AssetPath":["assets/assetbundles/prefabs/cube2.prefab"],"Version":"1.0.0","Size":"45910","MD5":"eb3bd9afd239cce91e12d0d78c7b05a7","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":""},"UIPanel":{"AbName":"ui/uipanel","AssetPath":["assets/assetbundles/ui/uipanel.prefab"],"Version":"1.0.0","Size":"24650","MD5":"1c91d9f7aff2ffd31cb31c3e37173ff7","Package":"","Updated":""},"LocalizedStrings":{"AbName":"config/binconfigdata/localizedstrings","AssetPath":["assets/assetbundles/config/binconfigdata/localizedstrings.bytes"],"Version":"1.0.0","Size":"4229","MD5":"dc9248fedf7eae92be50faf813e2aeb5","Package":"","Updated":""},"Sheet1":{"AbName":"config/binconfigdata/sheet1","AssetPath":["assets/assetbundles/config/binconfigdata/sheet1.bytes"],"Version":"1.0.0","Size":"1873","MD5":"568c0ae8f2707d57d61cd5920d25a34b","Package":"","Updated":""},"Sheet2":{"AbName":"config/binconfigdata/sheet2","AssetPath":["assets/assetbundles/config/binconfigdata/sheet2.bytes"],"Version":"1.0.0","Size":"1948","MD5":"b98fccd188e1241e9a1b5e478c3f3612","Package":"","Updated":""},"Cube1fsdf":{"AbName":"prefabs/pf2/cube2sdfwe","AssetPath":["assets/assetbundles/prefabs/pf2/cube1fsdf.prefab"],"Version":"1.0.0","Size":"45910","MD5":"eb3bd9afd239cce91e12d0d78c7b05a7","Package":"","Updated":""},"Cube2sdfwe":{"AbName":"prefabs/pf2/cube2sdfwe","AssetPath":["assets/assetbundles/prefabs/pf2/cube2sdfwe.prefab"],"Version":"1.0.0","Size":"45910","MD5":"eb3bd9afd239cce91e12d0d78c7b05a7","Package":"","Updated":""},"Cubeljk":{"AbName":"prefabs/pf2/cube2sdfwe","AssetPath":["assets/assetbundles/prefabs/pf2/cubeljk.prefab"],"Version":"1.0.0","Size":"45910","MD5":"eb3bd9afd239cce91e12d0d78c7b05a7","Package":"","Updated":""},"Audio":{"AbName":"audio","AssetPath":["assets/assetbundles/audio/2852.wav","assets/assetbundles/audio/button1.wav","assets/assetbundles/audio/\u5927\u98CE-wq20070525.mp3","assets/assetbundles/audio/\u7B1B\u5B501-mcx20070508.wav"],"Version":"1.0.0","Size":"","MD5":"","Package":"","Updated":""},"Code":{"AbName":"code","AssetPath":["assets/assetbundles/code/hotupdate.bytes"],"Version":"1.0.0","Size":"","MD5":"","Package":"","Updated":""},"Config":{"AbName":"config","AssetPath":[],"Version":"1.0.0","Size":"","MD5":"","Package":"","Updated":""},"Materials":{"AbName":"materials","AssetPath":["assets/assetbundles/materials/00029-3980031510mat.mat","assets/assetbundles/materials/00031-1829375853mat.mat"],"Version":"1.0.0","Size":"","MD5":"","Package":"","Updated":""},"Package_0":{"AbName":"package_0","AssetPath":["assets/assetbundles/package_0/uibg.mat"],"Version":"1.0.0","Size":"","MD5":"","Package":"","Updated":""},"Package_1":{"AbName":"package_1","AssetPath":["assets/assetbundles/package_1/uibg 1.mat"],"Version":"1.0.0","Size":"","MD5":"","Package":"","Updated":""},"Prefabs":{"AbName":"prefabs","AssetPath":["assets/assetbundles/prefabs/cube.prefab","assets/assetbundles/prefabs/cube1.prefab","assets/assetbundles/prefabs/cube2.prefab"],"Version":"1.0.0","Size":"","MD5":"","Package":"","Updated":""},"Textures":{"AbName":"textures","AssetPath":["assets/assetbundles/textures/00023-3589759801.png","assets/assetbundles/textures/00029-3980031510.png","assets/assetbundles/textures/00031-1829375853.png"],"Version":"1.0.0","Size":"","MD5":"","Package":"","Updated":""},"UI":{"AbName":"ui","AssetPath":["assets/assetbundles/ui/uipanel.prefab"],"Version":"1.0.0","Size":"","MD5":"","Package":"","Updated":""},"BinConfigData":{"AbName":"config/binconfigdata","AssetPath":["assets/assetbundles/config/binconfigdata/localizedstrings.bytes","assets/assetbundles/config/binconfigdata/sheet1.bytes","assets/assetbundles/config/binconfigdata/sheet2.bytes"],"Version":"1.0.0","Size":"","MD5":"","Package":"","Updated":""},"pf2":{"AbName":"prefabs/pf2","AssetPath":["assets/assetbundles/prefabs/pf2/cube1fsdf.prefab","assets/assetbundles/prefabs/pf2/cube2sdfwe.prefab","assets/assetbundles/prefabs/pf2/cubeljk.prefab"],"Version":"1.0.0","Size":"","MD5":"","Package":"","Updated":""},"Windows":{"AbName":"Windows","AssetPath":[],"Version":"1.0.0","Size":"2239","MD5":"ac9a288bb32e1db47f16f08ba8df12ce","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":"13b86da06a7db926e88afc306c3081a9","Package":"","Updated":""},"button1":{"AbName":"audio/button1","AssetPath":["assets/assetbundles/audio/button1.wav"],"Version":"1.0.0","Size":"15567","MD5":"a818c3ecef6f0dad489e3351a3a09485","Package":"","Updated":""},"\u5927\u98CE-WQ20070525":{"AbName":"audio/\u5927\u98CE-wq20070525","AssetPath":["assets/assetbundles/audio/\u5927\u98CE-wq20070525.mp3"],"Version":"1.0.0","Size":"559199","MD5":"0f826f53d47e04a0a5f095fe3814ea25","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":"eba3243db88378c73f230c78262c8425","Package":"","Updated":""},"F8Framework.F8ExcelDataClass":{"AbName":"code/f8framework.f8exceldataclass","AssetPath":["assets/assetbundles/code/f8framework.f8exceldataclass.bytes"],"Version":"1.0.0","Size":"7078","MD5":"3a09bde3081206fcababacdb9d7bbce6","Package":"","Updated":""},"F8Framework.Launcher":{"AbName":"code/f8framework.launcher","AssetPath":["assets/assetbundles/code/f8framework.launcher.bytes"],"Version":"1.0.0","Size":"6016","MD5":"e6b4a42e4d337f5da62a0522eb94407b","Package":"","Updated":""},"00029-3980031510mat":{"AbName":"materials/00029-3980031510mat","AssetPath":["assets/assetbundles/materials/00029-3980031510mat.mat"],"Version":"1.0.0","Size":"148099","MD5":"04c0074f0f84c290f51ea433fc33a70b","Package":"","Updated":""},"00031-1829375853mat":{"AbName":"materials/00031-1829375853mat","AssetPath":["assets/assetbundles/materials/00031-1829375853mat.mat"],"Version":"1.0.0","Size":"343362","MD5":"36711d5c4122c0a0d136f5e171532554","Package":"","Updated":""},"uibg":{"AbName":"package_0/uibg","AssetPath":["assets/assetbundles/package_0/uibg.mat"],"Version":"1.0.0","Size":"19073","MD5":"f26d78dd64848ba3974746e86d0f221d","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":"00668a40d64cf36bc99c455f6887822b","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":"43676","MD5":"a3a0f0d78c559fac7de9bd120f423be3","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":""},"UIPanel":{"AbName":"ui/uipanel","AssetPath":["assets/assetbundles/ui/uipanel.prefab"],"Version":"1.0.0","Size":"24667","MD5":"cacfa47a722c73f6f84e209953a427d4","Package":"","Updated":""},"LocalizedStrings":{"AbName":"config/binconfigdata/localizedstrings","AssetPath":["assets/assetbundles/config/binconfigdata/localizedstrings.bytes"],"Version":"1.0.0","Size":"4352","MD5":"cac53dbbdf08cbdd30090fd749482b70","Package":"","Updated":""},"Sheet1":{"AbName":"config/binconfigdata/sheet1","AssetPath":["assets/assetbundles/config/binconfigdata/sheet1.bytes"],"Version":"1.0.0","Size":"1878","MD5":"fa03774274bd31ad6016853b0c0f6f7c","Package":"","Updated":""},"Sheet2":{"AbName":"config/binconfigdata/sheet2","AssetPath":["assets/assetbundles/config/binconfigdata/sheet2.bytes"],"Version":"1.0.0","Size":"1948","MD5":"713d3ee718ebb22fa6286a75f288823a","Package":"","Updated":""},"Cube1fsdf":{"AbName":"prefabs/pf2/cube1fsdf","AssetPath":["assets/assetbundles/prefabs/pf2/cube1fsdf.prefab"],"Version":"1.0.0","Size":"3441","MD5":"8521162c9bec5ea8904efb35abf5a931","Package":"","Updated":""},"Cube2sdfwe":{"AbName":"prefabs/pf2/cube2sdfwe","AssetPath":["assets/assetbundles/prefabs/pf2/cube2sdfwe.prefab"],"Version":"1.0.0","Size":"43493","MD5":"5f18e02b5cced466e08198ddf9aeb945","Package":"","Updated":""},"Cubeljk":{"AbName":"prefabs/pf2/cubeljk","AssetPath":["assets/assetbundles/prefabs/pf2/cubeljk.prefab"],"Version":"1.0.0","Size":"3446","MD5":"12d60bad95667f89fb5d96443aa8ee23","Package":"","Updated":""},"Audio":{"AbName":"audio","AssetPath":["assets/assetbundles/audio/2852.wav","assets/assetbundles/audio/button1.wav","assets/assetbundles/audio/\u5927\u98CE-wq20070525.mp3","assets/assetbundles/audio/\u7B1B\u5B501-mcx20070508.wav"],"Version":"1.0.0","Size":"","MD5":"","Package":"","Updated":""},"Code":{"AbName":"code","AssetPath":["assets/assetbundles/code/f8framework.f8exceldataclass.bytes","assets/assetbundles/code/f8framework.launcher.bytes"],"Version":"1.0.0","Size":"","MD5":"","Package":"","Updated":""},"Config":{"AbName":"config","AssetPath":[],"Version":"1.0.0","Size":"","MD5":"","Package":"","Updated":""},"Materials":{"AbName":"materials","AssetPath":["assets/assetbundles/materials/00029-3980031510mat.mat","assets/assetbundles/materials/00031-1829375853mat.mat"],"Version":"1.0.0","Size":"","MD5":"","Package":"","Updated":""},"Package_0":{"AbName":"package_0","AssetPath":["assets/assetbundles/package_0/uibg.mat"],"Version":"1.0.0","Size":"","MD5":"","Package":"","Updated":""},"Package_1":{"AbName":"package_1","AssetPath":["assets/assetbundles/package_1/uibg 1.mat"],"Version":"1.0.0","Size":"","MD5":"","Package":"","Updated":""},"Prefabs":{"AbName":"prefabs","AssetPath":["assets/assetbundles/prefabs/cube.prefab","assets/assetbundles/prefabs/cube1.prefab","assets/assetbundles/prefabs/cube2.prefab"],"Version":"1.0.0","Size":"","MD5":"","Package":"","Updated":""},"Textures":{"AbName":"textures","AssetPath":["assets/assetbundles/textures/00023-3589759801.png","assets/assetbundles/textures/00029-3980031510.png","assets/assetbundles/textures/00031-1829375853.png"],"Version":"1.0.0","Size":"","MD5":"","Package":"","Updated":""},"UI":{"AbName":"ui","AssetPath":["assets/assetbundles/ui/uipanel.prefab"],"Version":"1.0.0","Size":"","MD5":"","Package":"","Updated":""},"BinConfigData":{"AbName":"config/binconfigdata","AssetPath":["assets/assetbundles/config/binconfigdata/localizedstrings.bytes","assets/assetbundles/config/binconfigdata/sheet1.bytes","assets/assetbundles/config/binconfigdata/sheet2.bytes"],"Version":"1.0.0","Size":"","MD5":"","Package":"","Updated":""},"pf2":{"AbName":"prefabs/pf2","AssetPath":["assets/assetbundles/prefabs/pf2/cube1fsdf.prefab","assets/assetbundles/prefabs/pf2/cube2sdfwe.prefab","assets/assetbundles/prefabs/pf2/cubeljk.prefab"],"Version":"1.0.0","Size":"","MD5":"","Package":"","Updated":""},"Windows":{"AbName":"Windows","AssetPath":[],"Version":"1.0.0","Size":"2455","MD5":"99881a0c284a02417e52a31bde2177b8","Package":"","Updated":""}} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index fa5ebc0..1777d91 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## [1.0.17] - 2024-06-21 +1.新增F8Framework.F8ExcelDataClass和F8Framework.Launcher程序集 +2.配置表生成的F8Framework.F8ExcelDataClass可用于HybridCLR热更 +3.增加导表后脚本编译完成,再打包AB步骤 +4.重新加载C#域后,AssetDatabase.Refresh需要增加delayCall延迟执行 +5.完善热更文档 +6.F8Framework.Tests程序集增加宏定义不参与打包 + ## [1.0.16] - 2024-05-26 1.优化资产管理代码 2.优化UI界面传入参数 diff --git a/ConfigData/F8DataManager/F8DataManager.asmref b/ConfigData/F8DataManager/F8DataManager.asmref deleted file mode 100644 index 082093f..0000000 --- a/ConfigData/F8DataManager/F8DataManager.asmref +++ /dev/null @@ -1,3 +0,0 @@ -{ - "reference": "F8Framework.Core" -} \ No newline at end of file diff --git a/ConfigData/F8DataManager/F8DataManager.cs b/ConfigData/F8DataManager/F8DataManager.cs index 793774f..d27a7b0 100644 --- a/ConfigData/F8DataManager/F8DataManager.cs +++ b/ConfigData/F8DataManager/F8DataManager.cs @@ -10,10 +10,10 @@ using System.Runtime.Serialization; using System.Runtime.Serialization.Formatters.Binary; using System.IO; -using F8Framework.F8ExcelDataClass; using LitJson; +using F8Framework.Core; -namespace F8Framework.Core +namespace F8Framework.F8ExcelDataClass { public class F8DataManager : ModuleSingleton, IModule { diff --git a/ConfigData/F8DataManager/F8DataManager.cs.meta b/ConfigData/F8DataManager/F8DataManager.cs.meta index 350cd91..4afb04f 100644 --- a/ConfigData/F8DataManager/F8DataManager.cs.meta +++ b/ConfigData/F8DataManager/F8DataManager.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 4a172b5ae5024df42a9d07f942b27864 +guid: cafe7e874fffb5b43a81ced5c565f4be MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/ConfigData/F8ExcelDataClass/F8Framework.F8ExcelDataClass.dll b/ConfigData/F8ExcelDataClass/F8Framework.F8ExcelDataClass.dll deleted file mode 100644 index 1ff1628..0000000 Binary files a/ConfigData/F8ExcelDataClass/F8Framework.F8ExcelDataClass.dll and /dev/null differ diff --git a/ConfigData/F8ExcelDataClass/F8Framework.F8ExcelDataClass.dll.meta b/ConfigData/F8ExcelDataClass/F8Framework.F8ExcelDataClass.dll.meta deleted file mode 100644 index 71a57b3..0000000 --- a/ConfigData/F8ExcelDataClass/F8Framework.F8ExcelDataClass.dll.meta +++ /dev/null @@ -1,33 +0,0 @@ -fileFormatVersion: 2 -guid: 78e68ccbe74dc0649bfae6c4886db7a5 -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - Any: - second: - enabled: 1 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - - first: - Windows Store Apps: WindowsStoreApps - second: - enabled: 0 - settings: - CPU: AnyCPU - userData: - assetBundleName: - assetBundleVariant: diff --git a/ConfigData/F8ExcelDataClass/LocalizedStrings.cs b/ConfigData/F8ExcelDataClass/LocalizedStrings.cs new file mode 100644 index 0000000..686e3a8 --- /dev/null +++ b/ConfigData/F8ExcelDataClass/LocalizedStrings.cs @@ -0,0 +1,23 @@ +/*Auto create +Don't Edit it*/ + +using System; +using System.Collections.Generic; + +namespace F8Framework.F8ExcelDataClass +{ + [Serializable] + public class LocalizedStringsItem + { + public int id; + public string TextID; + public string ChineseSimplified; + public string English; + } + + [Serializable] + public class LocalizedStrings + { + public Dictionary Dict = new Dictionary(); + } +} diff --git a/ConfigData/F8ExcelDataClass/LocalizedStrings.cs.meta b/ConfigData/F8ExcelDataClass/LocalizedStrings.cs.meta new file mode 100644 index 0000000..fa21ffc --- /dev/null +++ b/ConfigData/F8ExcelDataClass/LocalizedStrings.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 52dd5d23e9052fd45a6ece4df295185c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ConfigData/F8ExcelDataClass/Sheet1.cs b/ConfigData/F8ExcelDataClass/Sheet1.cs new file mode 100644 index 0000000..c1a78fd --- /dev/null +++ b/ConfigData/F8ExcelDataClass/Sheet1.cs @@ -0,0 +1,26 @@ +/*Auto create +Don't Edit it*/ + +using System; +using System.Collections.Generic; + +namespace F8Framework.F8ExcelDataClass +{ + [Serializable] + public class Sheet1Item + { + public int id; + public string name; + public float[] price; + public int fddfd; + public float aaasd; + public int[] dfdfd; + public string[] gggaa; + } + + [Serializable] + public class Sheet1 + { + public Dictionary Dict = new Dictionary(); + } +} diff --git a/ConfigData/F8ExcelDataClass/Sheet1.cs.meta b/ConfigData/F8ExcelDataClass/Sheet1.cs.meta new file mode 100644 index 0000000..d3b3a8b --- /dev/null +++ b/ConfigData/F8ExcelDataClass/Sheet1.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1ad81ab4ba8a2c34688c03b8c0833302 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ConfigData/F8ExcelDataClass/Sheet2.cs b/ConfigData/F8ExcelDataClass/Sheet2.cs new file mode 100644 index 0000000..e6d377f --- /dev/null +++ b/ConfigData/F8ExcelDataClass/Sheet2.cs @@ -0,0 +1,26 @@ +/*Auto create +Don't Edit it*/ + +using System; +using System.Collections.Generic; + +namespace F8Framework.F8ExcelDataClass +{ + [Serializable] + public class Sheet2Item + { + public int id; + public string name; + public float[] price; + public int fddfd; + public float aaasd; + public int[] dfdfd; + public string[] gggaa; + } + + [Serializable] + public class Sheet2 + { + public Dictionary Dict = new Dictionary(); + } +} diff --git a/ConfigData/F8ExcelDataClass/Sheet2.cs.meta b/ConfigData/F8ExcelDataClass/Sheet2.cs.meta new file mode 100644 index 0000000..4c2d0c7 --- /dev/null +++ b/ConfigData/F8ExcelDataClass/Sheet2.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 37ed708010051e34f8edb7a875e6e994 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ConfigData/F8Framework.F8ExcelDataClass.asmdef b/ConfigData/F8Framework.F8ExcelDataClass.asmdef new file mode 100644 index 0000000..41e20f5 --- /dev/null +++ b/ConfigData/F8Framework.F8ExcelDataClass.asmdef @@ -0,0 +1,16 @@ +{ + "name": "F8Framework.F8ExcelDataClass", + "references": [ + "F8Framework.Core", + "LitJson" + ], + "includePlatforms": [], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": false, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/ConfigData/F8DataManager/F8DataManager.asmref.meta b/ConfigData/F8Framework.F8ExcelDataClass.asmdef.meta similarity index 56% rename from ConfigData/F8DataManager/F8DataManager.asmref.meta rename to ConfigData/F8Framework.F8ExcelDataClass.asmdef.meta index 9caba6b..e7a72a6 100644 --- a/ConfigData/F8DataManager/F8DataManager.asmref.meta +++ b/ConfigData/F8Framework.F8ExcelDataClass.asmdef.meta @@ -1,6 +1,6 @@ fileFormatVersion: 2 -guid: f43dea301ccf0894c9e7f38ef353f408 -AssemblyDefinitionReferenceImporter: +guid: cec5fc8f5a6c85b4684802d40d73d7f3 +AssemblyDefinitionImporter: externalObjects: {} userData: assetBundleName: diff --git a/Editor/AssetManager/ABBuildTool.cs b/Editor/AssetManager/ABBuildTool.cs index b0c9b82..594cf4a 100644 --- a/Editor/AssetManager/ABBuildTool.cs +++ b/Editor/AssetManager/ABBuildTool.cs @@ -24,18 +24,20 @@ public static void BuildAllAB() // 获取“StreamingAssets”文件夹路径(不一定这个文件夹,可自定义) string strABOutPAthDir = URLSetting.GetAssetBundlesOutPath(); - LogF8.LogAsset("生成AssetBundleMap.json,生成ResourceMap.json"); GenerateAssetNames(); GenerateResourceNames(); + LogF8.LogAsset("自动设置AssetBundleName(AB名为空时)"); AssetDatabase.Refresh(); FileTools.CheckDirAndCreateWhenNeeded(strABOutPAthDir); AssetDatabase.Refresh(); + + Caching.ClearCache(); - LogF8.LogAsset("打包AssetBundle:" + URLSetting.GetAssetBundlesOutPath() + " 当前打包平台:" + EditorUserBuildSettings.activeBuildTarget); // 打包生成AB包 (目标平台自动根据当前平台设置,WebGL不可使用BuildAssetBundleOptions.None压缩) BuildPipeline.BuildAssetBundles(strABOutPAthDir, BuildAssetBundleOptions.ChunkBasedCompression, EditorUserBuildSettings.activeBuildTarget); - + LogF8.LogAsset("打包AssetBundle:" + URLSetting.GetAssetBundlesOutPath() + " 当前打包平台:" + EditorUserBuildSettings.activeBuildTarget); + AssetDatabase.Refresh(); // 清理多余文件夹和ab @@ -44,6 +46,9 @@ public static void BuildAllAB() // 等待AB打包完成,再写入数据 GenerateAssetNames(true); GenerateResourceNames(true); + LogF8.LogAsset("写入资产数据 生成:AssetBundleMap.json,生成:ResourceMap.json"); + + AssetDatabase.Refresh(); LogF8.LogAsset("资产打包成功!"); } @@ -165,9 +170,11 @@ public static string SetAssetBundleName(string path) { bundleName = Path.ChangeExtension(path, null).Replace(URLSetting.AssetBundlesPath, ""); } + if (!ai.assetBundleName.Equals(bundleName) && ai.assetBundleName.IsNullOrEmpty()) { ai.assetBundleName = bundleName; + EditorUtility.SetDirty(ai); } return ai.assetBundleName; } @@ -211,7 +218,7 @@ public static void GenerateAssetNames(bool isWrite = false) { continue; } - + if (tempNames.Contains(fileNameWithoutExtension.ToLower())) { LogF8.LogError("AssetName重复,请检查资源地址(大小写不敏感):" + filePath); diff --git a/Editor/AssetManager/AssetSetABName.cs b/Editor/AssetManager/AssetSetABName.cs index c532264..6ea353c 100644 --- a/Editor/AssetManager/AssetSetABName.cs +++ b/Editor/AssetManager/AssetSetABName.cs @@ -27,6 +27,7 @@ private static void SetAssetBundleNameIsFolderName() if (!string.IsNullOrEmpty(ai.assetBundleName)) { ai.assetBundleName = null; + EditorUtility.SetDirty(ai); } LogF8.Log("文件" + assetPath); } @@ -36,6 +37,7 @@ private static void SetAssetBundleNameIsFolderName() if (!string.IsNullOrEmpty(aiDir.assetBundleName)) { aiDir.assetBundleName = null; + EditorUtility.SetDirty(aiDir); } LogF8.Log("文件夹" + assetPath); @@ -47,6 +49,7 @@ private static void SetAssetBundleNameIsFolderName() if (!string.IsNullOrEmpty(ai.assetBundleName)) { ai.assetBundleName = null; + EditorUtility.SetDirty(ai); } } // 获取所有文件 @@ -59,12 +62,13 @@ private static void SetAssetBundleNameIsFolderName() if (!string.IsNullOrEmpty(ai.assetBundleName)) { ai.assetBundleName = null; + EditorUtility.SetDirty(ai); } LogF8.Log("文件" + _assetPath); } } } - + AssetDatabase.Refresh(); LogF8.LogAsset("已清空所有选中的资产AB名"); } @@ -96,6 +100,7 @@ private static void SetAssetBundleSameName() { ai.assetBundleName = FirstName; } + EditorUtility.SetDirty(ai); } LogF8.Log("文件" + assetPath); } @@ -122,12 +127,13 @@ private static void SetAssetBundleSameName() { ai.assetBundleName = FirstName; } + EditorUtility.SetDirty(ai); } LogF8.Log("文件" + _assetPath); } } } - + AssetDatabase.Refresh(); LogF8.LogAsset("设置所有AB名为:" + FirstName); } } diff --git a/Editor/ExcelTool/ExcelDataTool.cs b/Editor/ExcelTool/ExcelDataTool.cs index 017a71e..299457c 100644 --- a/Editor/ExcelTool/ExcelDataTool.cs +++ b/Editor/ExcelTool/ExcelDataTool.cs @@ -9,6 +9,8 @@ using UnityEngine; using UnityEditor; using Excel; +using UnityEditor.Compilation; +using Assembly = System.Reflection.Assembly; #if UNITY_WEBGL using LitJson; #else @@ -29,13 +31,13 @@ public const string public const string ExcelPath = "/StreamingAssets/config"; //需要导表的目录 public const string DLLFolder = "/F8Framework/ConfigData"; //存放dll目录 public const string FileIndexFile = "config/fileindex.txt"; //fileindex文件目录 - private static List codeList; //存放所有生成的类的代码 + private static Dictionary codeList; //存放所有生成的类的代码 private static Dictionary> dataDict; //存放所有数据表内的数据,key:类名 value:数据 // 使用StringBuilder来优化字符串的重复构造 private static StringBuilder FileIndex = new StringBuilder(); - + private static string GetScriptPath() { MonoScript monoScript = MonoScript.FromScriptableObject(CreateInstance()); @@ -51,13 +53,26 @@ private static string GetScriptPath() private static void CreateAsmdefFile() { - // 创建.asmref文件的路径 - string asmrefPath = Application.dataPath + DataManagerFolder + "/F8DataManager.asmref"; + // 创建.asmdef文件的路径 + string asmrefPath = Application.dataPath + DLLFolder + "/" + CODE_NAMESPACE + ".asmdef"; FileTools.CheckFileAndCreateDirWhenNeeded(asmrefPath); // 创建一个新的.asmdef文件 string asmdefContent = @"{ - ""reference"": ""F8Framework.Core"" + ""name"": ""F8Framework.F8ExcelDataClass"", + ""references"": [ + ""F8Framework.Core"", + ""LitJson"" + ], + ""includePlatforms"": [], + ""excludePlatforms"": [], + ""allowUnsafeCode"": false, + ""overrideReferences"": false, + ""precompiledReferences"": [], + ""autoReferenced"": false, + ""defineConstraints"": [], + ""versionDefines"": [], + ""noEngineReferences"": false }"; // 将内容写入.asmdef文件 @@ -88,17 +103,19 @@ public static void LoadAllExcelData() } string F8DataManagerPath = FileTools.FormatToUnityPath(FileTools.TruncatePath(GetScriptPath(), 3)) + "/ConfigData/F8DataManager"; - FileTools.SafeDeleteDir(F8DataManagerPath); + FileTools.SafeClearDir(F8DataManagerPath); FileTools.CheckDirAndCreateWhenNeeded(F8DataManagerPath); string F8ExcelDataClassPath = FileTools.FormatToUnityPath(FileTools.TruncatePath(GetScriptPath(), 3)) + "/ConfigData/F8ExcelDataClass"; - FileTools.SafeDeleteDir(F8ExcelDataClassPath); + FileTools.SafeClearDir(F8ExcelDataClassPath); FileTools.CheckDirAndCreateWhenNeeded(F8ExcelDataClassPath); + string F8ExcelDataClassPathDLL = FileTools.FormatToUnityPath(FileTools.TruncatePath(GetScriptPath(), 3)) + "/ConfigData/" + CODE_NAMESPACE + ".asmdef"; + FileTools.SafeDeleteFile(F8ExcelDataClassPathDLL); CreateAsmdefFile(); AssetDatabase.Refresh(); if (codeList == null) { - codeList = new List(); + codeList = new Dictionary(); } else { @@ -113,8 +130,7 @@ public static void LoadAllExcelData() { dataDict.Clear(); } - - float step = 1f; + FileIndex.Clear(); FileTools.SafeDeleteFile(URLSetting.CS_STREAMINGASSETS_URL + FileIndexFile); FileTools.SafeDeleteFile(URLSetting.CS_STREAMINGASSETS_URL + FileIndexFile + ".meta"); @@ -122,7 +138,6 @@ public static void LoadAllExcelData() FileTools.CheckFileAndCreateDirWhenNeeded(URLSetting.CS_STREAMINGASSETS_URL + FileIndexFile); foreach (string item in files) { - step++; GetExcelData(item); OnLogCallBack(item.Substring(item.LastIndexOf('\\') + 1)); } @@ -132,29 +147,81 @@ public static void LoadAllExcelData() EditorUtility.DisplayDialog("注意!!!", "\n暂无可以导入的数据表!", "确定"); throw new Exception("暂无可以导入的数据表!"); } - //编译代码,生成包含所有数据表内数据类型的dll - Assembly assembly = CompileCode(codeList.ToArray()); + GenerateCodeFiles(codeList); + ScriptGenerator.CreateDataManager(codeList); AssetDatabase.Refresh(); + // 等待脚本编译完成 + EditorPrefs.SetBool("compilationFinished", false); + CompilationPipeline.compilationFinished += (object s) => + { + EditorPrefs.SetBool("compilationFinished", true); + }; + } + + // 等待脚本编译完成 + [UnityEditor.Callbacks.DidReloadScripts] + private static void AllScriptsReloaded() + { + if (EditorPrefs.GetBool("compilationFinished", false) == false) + { + return; + } + EditorPrefs.SetBool("compilationFinished", false); + LogF8.LogConfig("导表后脚本编译完成!"); + Assembly assembly = Util.Assembly.GetAssembly(CODE_NAMESPACE); //准备序列化数据 string BinDataPath = Application.dataPath + BinDataFolder; //序列化后的数据存放路径 if (Directory.Exists(BinDataPath)) Directory.Delete(BinDataPath, true); //删除旧的数据文件 Directory.CreateDirectory(BinDataPath); - step = 1; + + string INPUT_PATH = Application.dataPath + ExcelPath; + var files = Directory.GetFiles(INPUT_PATH, "*.*", SearchOption.AllDirectories) + .Where(s => s.EndsWith(".xls") || s.EndsWith(".xlsx")).ToArray(); + if (codeList == null) + { + codeList = new Dictionary(); + } + else + { + codeList.Clear(); + } + if (dataDict == null) + { + dataDict = new Dictionary>(); + } + else + { + dataDict.Clear(); + } + foreach (string item in files) + { + GetExcelData(item); + } + foreach (KeyValuePair> each in dataDict) { - step++; //Assembly.CreateInstance 方法 (String) 使用区分大小写的搜索,从此程序集中查找指定的类型,然后使用系统激活器创建它的实例化对象 object container = assembly.CreateInstance(CODE_NAMESPACE + "." + each.Key); Type temp = assembly.GetType(CODE_NAMESPACE + "." + each.Key + "Item"); //序列化数据 Serialize(container, temp, each.Value, BinDataPath); } - ScriptGenerator.CreateDataManager(assembly); - AssetDatabase.Refresh(); + + // 如果 Unity 检测到任何脚本更改,则会重新加载 C# 域。这样做的原因是可能已创建新的脚本化导入器 (Scripted Importer), + // 它们的逻辑可能会影响“刷新”队列中的资源导入结果。此步骤会重新启动 Refresh() 以确保所有新的脚本化导入器生效。 + UnityEditor.EditorApplication.delayCall += () => + { + AssetDatabase.Refresh(); + if (EditorPrefs.GetBool("compilationFinishedBuildAB", false) == true) + { + ABBuildTool.BuildAllAB(); + } + EditorPrefs.SetBool("compilationFinishedBuildAB", false); + }; LogF8.LogConfig("导表成功!"); } - + [UnityEditor.MenuItem("开发工具/运行时读取Excel _F7", false, 101)] public static void ReLoadExcelData() { @@ -267,8 +334,12 @@ private static void GetExcelData(string inputPath) { //根据刚才的数据来生成C#脚本 ScriptGenerator generator = new ScriptGenerator(inputPath, className, names, types); - //所有生成的类的代码最终保存在这个链表中 - codeList.Add(generator.Generate()); + //所有生成的类的代码最终保存在这 + if (codeList.ContainsKey(className)) + { + throw new Exception("类名重复: " + className + " ,路径: " + inputPath); + } + codeList.Add(className, generator.Generate()); if (dataDict.ContainsKey(className)) { throw new Exception("类名重复: " + className + " ,路径: " + inputPath); @@ -313,6 +384,21 @@ private static Assembly CompileCode(string[] scripts) return cr.CompiledAssembly; } + // 生成代码文件 + public static void GenerateCodeFiles(Dictionary codeList) + { + string path = Application.dataPath + DLLFolder + "/F8ExcelDataClass"; + FileTools.SafeClearDir(path);// 删除旧文件 + + // 将每个脚本写入独立的 .cs 文件 + foreach (var kvp in codeList) + { + string filePath = $"{path}/{kvp.Key}.cs"; + File.WriteAllText(filePath, kvp.Value); + LogF8.LogConfig($"已生成代码 " + path + "/" + kvp.Key + ""); + } + } + //序列化对象 private static void Serialize(object container, Type temp, List dataList, string BinDataPath) { @@ -320,7 +406,7 @@ private static void Serialize(object container, Type temp, List da foreach (ConfigData[] datas in dataList) { //Type.FullName 获取该类型的完全限定名称,包括其命名空间,但不包括程序集。 - object t = temp.Assembly.CreateInstance(temp.FullName); + object t = Util.Assembly.GetTypeInstance(temp.FullName); foreach (ConfigData data in datas) { //Type.GetField(String) 搜索Type内指定名称的公共字段。 @@ -360,12 +446,23 @@ private static void Serialize(object container, Type temp, List da // 记录日志 LogF8.LogConfig("已序列化 " + BinDataPath + "/" + container.GetType().Name + ".json"); #else - IFormatter f = new BinaryFormatter(); - Stream s = new FileStream(BinDataPath + "/" + container.GetType().Name + ".bytes", FileMode.OpenOrCreate, - FileAccess.Write, FileShare.Write); - f.Serialize(s, container); - LogF8.LogConfig("已序列化 " + BinDataPath + "/" + container.GetType().Name + ".bytes"); - s.Close(); + try + { + IFormatter formatter = new BinaryFormatter(); + string filePath = Path.Combine(BinDataPath, container.GetType().Name + ".bytes"); + + // 使用 using 语句确保流被正确关闭 + using (Stream stream = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None)) + { + formatter.Serialize(stream, container); + } + + LogF8.LogConfig($"已序列化 {BinDataPath}/{container.GetType().Name}.bytes"); + } + catch (Exception ex) + { + Debug.LogError($"序列化失败: {ex.Message}"); + } #endif } } diff --git a/Editor/ExcelTool/SupportType.cs b/Editor/ExcelTool/SupportType.cs index cef04a7..882a5e7 100644 --- a/Editor/ExcelTool/SupportType.cs +++ b/Editor/ExcelTool/SupportType.cs @@ -4,6 +4,7 @@ using System; using UnityEngine; using System.IO; +using System.Linq; using System.Reflection; //脚本生成器 @@ -44,26 +45,25 @@ private string CreateCode(string ClassName, string[] types, string[] fields) classSource.Append("Don't Edit it*/\n"); classSource.Append("\n"); classSource.Append("using System;\n"); - classSource.Append("using System.Reflection;\n"); - classSource.Append("using System.Collections.Generic;\n"); + classSource.Append("using System.Collections.Generic;\n\n"); classSource.Append("namespace " + ExcelDataTool.CODE_NAMESPACE + "\n"); classSource.Append("{\n"); - classSource.Append("[Serializable]\n"); - classSource.Append("public class " + ClassName + "Item\n"); //表里每一条数据的类型名为表类型名加Item - classSource.Append("{\n"); + classSource.Append("\t[Serializable]\n"); + classSource.Append("\tpublic class " + ClassName + "Item\n"); //表里每一条数据的类型名为表类型名加Item + classSource.Append("\t{\n"); //设置成员 for (int i = 0; i < fields.Length; ++i) { classSource.Append(PropertyString(types[i], fields[i])); } - classSource.Append("}\n"); + classSource.Append("\t}\n"); //生成Container - classSource.Append("\n"); - classSource.Append("[Serializable]\n"); - classSource.Append("public class " + ClassName + "\n"); - classSource.Append("{\n"); + classSource.Append("\t\n"); + classSource.Append("\t[Serializable]\n"); + classSource.Append("\tpublic class " + ClassName + "\n"); + classSource.Append("\t{\n"); string idType = ""; for (int i = 0; i < fields.Length; i++) { @@ -74,9 +74,9 @@ private string CreateCode(string ClassName, string[] types, string[] fields) } } - classSource.Append("\tpublic " + "Dictionary<" + idType + ", " + ClassName + "Item" + " > " + " Dict" + + classSource.Append("\t\tpublic " + "Dictionary<" + idType + ", " + ClassName + "Item" + "> " + "Dict" + " = new Dictionary<" + idType + ", " + ClassName + "Item" + ">();\n"); - classSource.Append("}\n"); + classSource.Append("\t}\n"); classSource.Append("}\n"); return classSource.ToString(); /* //生成的条目数据类 @@ -179,11 +179,11 @@ private string GetTrueType(string type) } //创建数据管理器脚本 - public static void CreateDataManager(Assembly assembly) + public static void CreateDataManager(Dictionary codeList) { - List list = new List(); - list.AddRange(assembly.GetTypes()); - IEnumerable types = list.FindAll(t => { return !t.Name.Contains("Item"); }); + List list = new List(); + list.AddRange(codeList.Keys); + IEnumerable types = list.FindAll(t => { return !t.Contains("Item"); }); StringBuilder source = new StringBuilder(); source.Append("/*\n"); @@ -199,47 +199,47 @@ public static void CreateDataManager(Assembly assembly) source.Append("using System.Runtime.Serialization;\n"); source.Append("using System.Runtime.Serialization.Formatters.Binary;\n"); source.Append("using System.IO;\n"); - source.Append("using " + ExcelDataTool.CODE_NAMESPACE + ";\n"); - source.Append("using LitJson;\n\n"); - source.Append("namespace F8Framework.Core\n"); + source.Append("using LitJson;\n"); + source.Append("using F8Framework.Core;\n\n"); + source.Append("namespace " + ExcelDataTool.CODE_NAMESPACE + "\n"); source.Append("{\n"); source.Append("\tpublic class F8DataManager : ModuleSingleton, IModule\n"); source.Append("\t{\n"); //定义变量 - foreach (Type t in types) + foreach (string t in types) { - source.Append("\t\tprivate " + t.Name + " p_" + t.Name + ";\n"); + source.Append("\t\tprivate " + t + " p_" + t + ";\n"); } source.Append("\n"); bool hasLocalizedStrings = false; //定义方法 - foreach (Type t in types) + foreach (string t in types) { - string typeName = t.Name + "Item"; //类型名 - string typeNameNotItem = t.Name; //类型名没item - string funcName = typeName.Remove(1).ToUpper() + typeName.Substring(1); //将类型名第一个字母大写 + string typeName = t + "Item"; //类型名 + string typeNameNotItem = t; //类型名没item + Type tempType = Util.Assembly.GetType(ExcelDataTool.CODE_NAMESPACE + "." + typeName); List fields = new List(); - fields.AddRange(list.Find(temp => temp.Name == typeName).GetFields()); //获取数据类的所有字段信息 + fields = Util.Assembly.GetTypeAllFields(tempType).ToList(); //获取数据类的所有字段信息 string idType = fields.Find(f => f.Name == "id" || f.Name == "ID" || f.Name == "iD" || f.Name == "Id") .FieldType.Name; //获取id的数据类型 source.Append("\t\tpublic " + typeName + " Get" + typeNameNotItem + "ByID" + "(" + idType + " id)\n"); source.Append("\t\t{\n"); source.Append("\t\t\t" + typeName + " t = null;\n"); - source.Append("\t\t\tp_" + t.Name + ".Dict.TryGetValue(id, out t);\n"); + source.Append("\t\t\tp_" + t + ".Dict.TryGetValue(id, out t);\n"); source.Append("\t\t\tif (t == null) LogF8.LogError(" + '"' + "找不到id: " + '"' + " + id " + "+ " + - '"' + " ,配置表: " + t.Name + '"' + ");\n"); + '"' + " ,配置表: " + t + '"' + ");\n"); source.Append("\t\t\treturn t;\n"); source.Append("\t\t}\n\n"); source.Append("\t\tpublic Dictionary" + " Get" + typeNameNotItem + "()\n"); source.Append("\t\t{\n"); - source.Append("\t\t\treturn p_" + t.Name + ".Dict;\n"); + source.Append("\t\t\treturn p_" + t + ".Dict;\n"); source.Append("\t\t}\n\n"); - if (t.Name == "LocalizedStrings") + if (t == "LocalizedStrings") { hasLocalizedStrings = true; } @@ -268,9 +268,9 @@ public static void CreateDataManager(Assembly assembly) //加载所有配置表 source.Append("\t\tpublic void LoadAll()\n"); source.Append("\t\t{\n"); - foreach (Type t in types) + foreach (string t in types) { - source.Append("\t\t\tp_" + t.Name + " = Load<" + t.Name + ">(" + '"' + t.Name + '"' + ") as " + t.Name + ";\n"); + source.Append("\t\t\tp_" + t + " = Load<" + t + ">(" + '"' + t + '"' + ") as " + t + ";\n"); } source.Append("\t\t}\n\n"); @@ -278,9 +278,9 @@ public static void CreateDataManager(Assembly assembly) //运行时加载所有配置表 source.Append("\t\tpublic void RuntimeLoadAll(Dictionary objs)\n"); source.Append("\t\t{\n"); - foreach (Type t in types) + foreach (string t in types) { - source.Append("\t\t\tp_" + t.Name + " = objs[" + '"' + t.Name + '"' + "] as " + t.Name + ";\n"); + source.Append("\t\t\tp_" + t + " = objs[" + '"' + t + '"' + "] as " + t + ";\n"); } source.Append("\t\t}\n\n"); @@ -288,9 +288,9 @@ public static void CreateDataManager(Assembly assembly) //异步加载所有配置表 source.Append("\t\tpublic IEnumerable LoadAllAsync()\n"); source.Append("\t\t{\n"); - foreach (Type t in types) + foreach (string t in types) { - source.Append("\t\t\tyield return LoadAsync<" + t.Name + ">("+ '"' + t.Name + '"' + ", result => " + "p_" + t.Name + " = result" + " as " + t.Name + ");\n"); + source.Append("\t\t\tyield return LoadAsync<" + t + ">("+ '"' + t + '"' + ", result => " + "p_" + t + " = result" + " as " + t + ");\n"); } source.Append("\t\t}\n\n"); @@ -304,9 +304,9 @@ public static void CreateDataManager(Assembly assembly) //异步加载所有配置表 source.Append("\t\tpublic IEnumerator LoadAllAsyncIEnumerator(Action onLoadComplete)\n"); source.Append("\t\t{\n"); - foreach (Type t in types) + foreach (string t in types) { - source.Append("\t\t\tyield return LoadAsync<" + t.Name + ">("+ '"' + t.Name + '"' + ", result => " + "p_" + t.Name + " = result" + " as " + t.Name + ");\n"); + source.Append("\t\t\tyield return LoadAsync<" + t + ">("+ '"' + t + '"' + ", result => " + "p_" + t + " = result" + " as " + t + ");\n"); } source.Append("\t\t\tonLoadComplete?.Invoke();\n"); source.Append("\t\t}\n\n"); @@ -384,7 +384,7 @@ public static void CreateDataManager(Assembly assembly) sw.NewLine = "\n"; // 设置行尾符为 UNIX 风格 sw.WriteLine(source.ToString()); - LogF8.LogConfig("已生成 " + path + "/" + ExcelDataTool.DataManagerName + ""); + LogF8.LogConfig("已生成代码 " + path + "/" + ExcelDataTool.DataManagerName + ""); sw.Close(); /* //生成的数据管理类如下 diff --git a/Editor/F8Helper/F8Helper.cs b/Editor/F8Helper/F8Helper.cs index f34eafa..78fe72e 100644 --- a/Editor/F8Helper/F8Helper.cs +++ b/Editor/F8Helper/F8Helper.cs @@ -10,10 +10,8 @@ public class F8Helper public static void F8Run() { GenerateCopyHotUpdateDll(); + EditorPrefs.SetBool("compilationFinishedBuildAB", true); LoadAllExcelData(); - BuildAssetBundles(); - - AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate); } [MenuItem("开发工具/生成并复制热更新Dll-F8")] @@ -24,7 +22,8 @@ public static void GenerateCopyHotUpdateDll() // FileTools.CheckDirAndCreateWhenNeeded(Application.dataPath + "/AssetBundles/Code"); // List hotUpdateDll = new List() // { - // "HotUpdate", // 自行添加需要热更的程序集 + // "F8Framework.F8ExcelDataClass", // 自行添加需要热更的程序集 + // "F8Framework.Launcher" // }; // foreach (var dll in hotUpdateDll) // { diff --git a/Runtime/Launcher.meta b/Launcher.meta similarity index 77% rename from Runtime/Launcher.meta rename to Launcher.meta index 1f9905d..425c1c4 100644 --- a/Runtime/Launcher.meta +++ b/Launcher.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 03014a77bd6f44c4a9745797be7ab12c +guid: d6ff4ab82ccf7994ba46c2b0138e84d4 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Launcher/F8Framework.Launcher.asmdef b/Launcher/F8Framework.Launcher.asmdef new file mode 100644 index 0000000..bc477c8 --- /dev/null +++ b/Launcher/F8Framework.Launcher.asmdef @@ -0,0 +1,17 @@ +{ + "name": "F8Framework.Launcher", + "rootNamespace": "", + "references": [ + "F8Framework.Core", + "F8Framework.F8ExcelDataClass" + ], + "includePlatforms": [], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": false, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/Launcher/F8Framework.Launcher.asmdef.meta b/Launcher/F8Framework.Launcher.asmdef.meta new file mode 100644 index 0000000..0a21546 --- /dev/null +++ b/Launcher/F8Framework.Launcher.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 6ef0fe8f047a13f40893c2fd4cdc1925 +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Runtime/Launcher/FF8.cs b/Launcher/FF8.cs similarity index 98% rename from Runtime/Launcher/FF8.cs rename to Launcher/FF8.cs index 33e6c2d..80deed3 100644 --- a/Runtime/Launcher/FF8.cs +++ b/Launcher/FF8.cs @@ -1,4 +1,7 @@ -namespace F8Framework.Core +using F8Framework.Core; +using F8Framework.F8ExcelDataClass; + +namespace F8Framework.Launcher { public static class FF8 { diff --git a/Runtime/Launcher/FF8.cs.meta b/Launcher/FF8.cs.meta similarity index 83% rename from Runtime/Launcher/FF8.cs.meta rename to Launcher/FF8.cs.meta index 4cc64b4..9647a5d 100644 --- a/Runtime/Launcher/FF8.cs.meta +++ b/Launcher/FF8.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: d59db9368b58db549b78948bc2a7e3f3 +guid: 45692f4cf84a4b749939ea141d3e5c56 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Launcher/GameLauncher.cs b/Launcher/GameLauncher.cs new file mode 100644 index 0000000..3342c42 --- /dev/null +++ b/Launcher/GameLauncher.cs @@ -0,0 +1,67 @@ +using System.Collections; +using F8Framework.Core; +using F8Framework.F8ExcelDataClass; +using UnityEngine; + +namespace F8Framework.Launcher +{ + public class GameLauncher : MonoBehaviour + { + IEnumerator Start() + { + // 初始化模块中心 + ModuleCenter.Initialize(this); + + // 初始化版本 + FF8.HotUpdate = ModuleCenter.CreateModule(); + + // 按顺序创建模块,可按需添加 + FF8.Message = ModuleCenter.CreateModule(); + FF8.Input = ModuleCenter.CreateModule(new DefaultInputHelper()); + FF8.Storage = ModuleCenter.CreateModule(); + FF8.Timer = ModuleCenter.CreateModule(); + FF8.Procedure = ModuleCenter.CreateModule(); + FF8.Network = ModuleCenter.CreateModule(); + FF8.FSM = ModuleCenter.CreateModule(); + FF8.GameObjectPool = ModuleCenter.CreateModule(); + FF8.Asset = ModuleCenter.CreateModule(); + // yield return AssetBundleManager.Instance.LoadAssetBundleManifest(); // WebGL专用 + FF8.Config = ModuleCenter.CreateModule(); + FF8.Audio = ModuleCenter.CreateModule(); + FF8.Tween = ModuleCenter.CreateModule(); + FF8.UI = ModuleCenter.CreateModule(); + // yield return F8DataManager.Instance.LoadLocalizedStringsIEnumerator(); // WebGL专用 + FF8.Local = ModuleCenter.CreateModule(); + FF8.SDK = ModuleCenter.CreateModule(); + FF8.Download = ModuleCenter.CreateModule(); + FF8.LogWriter = ModuleCenter.CreateModule(); + + StartGame(); + yield break; + } + + // 开始游戏 + public void StartGame() + { + + } + + void Update() + { + // 更新模块 + ModuleCenter.Update(); + } + + void LateUpdate() + { + // 更新模块 + ModuleCenter.LateUpdate(); + } + + void FixedUpdate() + { + // 更新模块 + ModuleCenter.FixedUpdate(); + } + } +} diff --git a/Runtime/Launcher/GameLauncher.cs.meta b/Launcher/GameLauncher.cs.meta similarity index 83% rename from Runtime/Launcher/GameLauncher.cs.meta rename to Launcher/GameLauncher.cs.meta index 2f36d6b..bb96716 100644 --- a/Runtime/Launcher/GameLauncher.cs.meta +++ b/Launcher/GameLauncher.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: afd0f61457d941b4aa172960bd75eea4 +guid: 489bdb284b61c3c409ee5397885d9c8c MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Runtime/Launcher/LICENSE.md b/Launcher/LICENSE.md similarity index 100% rename from Runtime/Launcher/LICENSE.md rename to Launcher/LICENSE.md diff --git a/Runtime/Launcher/LICENSE.md.meta b/Launcher/LICENSE.md.meta similarity index 75% rename from Runtime/Launcher/LICENSE.md.meta rename to Launcher/LICENSE.md.meta index 692163a..3b2e03b 100644 --- a/Runtime/Launcher/LICENSE.md.meta +++ b/Launcher/LICENSE.md.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: e8849a5c8f499e74c80ec288a73e89ea +guid: 5c04255fee1c50f498da58ef398e1875 TextScriptImporter: externalObjects: {} userData: diff --git a/README.md b/README.md index 9a0d9f4..b718189 100644 --- a/README.md +++ b/README.md @@ -65,8 +65,8 @@ Unity 2021.3.15f1+ ## 新手指南 -* [游戏启动器:](https://github.com/TippingGame/F8Framework/blob/main/Runtime/Launcher/GameLauncher.cs)游戏启动器示例。[GameLauncher.cs](https://github.com/TippingGame/F8Framework/blob/main/Runtime/Launcher/GameLauncher.cs) -* [模块自定义改名:](https://github.com/TippingGame/F8Framework/blob/main/Runtime/Launcher/FF8.cs)模块自定义改名。[FF8.cs](https://github.com/TippingGame/F8Framework/blob/main/Runtime/Launcher/FF8.cs) +* [游戏启动器:](https://github.com/TippingGame/F8Framework/blob/main/Launcher/GameLauncher.cs)游戏启动器示例。[GameLauncher.cs](https://github.com/TippingGame/F8Framework/blob/main/Launcher/GameLauncher.cs) +* [模块自定义改名:](https://github.com/TippingGame/F8Framework/blob/main/Launcher/FF8.cs)模块自定义改名。[FF8.cs](https://github.com/TippingGame/F8Framework/blob/main/Launcher/FF8.cs) ## 视频教程 @@ -122,6 +122,6 @@ In the Unity Package Manager, add the F8Framework package using Git URL. ## GUIDE -* [GameLauncher:](https://github.com/TippingGame/F8Framework/blob/main/Runtime/Launcher/GameLauncher.cs)Game Launcher Example.[GameLauncher.cs](https://github.com/TippingGame/F8Framework/blob/main/Runtime/Launcher/GameLauncher.cs) -* [Module renaming:](https://github.com/TippingGame/F8Framework/blob/main/Runtime/Launcher/FF8.cs)Module customization renaming.[FF8.cs](https://github.com/TippingGame/F8Framework/blob/main/Runtime/Launcher/FF8.cs) +* [GameLauncher:](https://github.com/TippingGame/F8Framework/blob/main/Launcher/GameLauncher.cs)Game Launcher Example.[GameLauncher.cs](https://github.com/TippingGame/F8Framework/blob/main/Launcher/GameLauncher.cs) +* [Module renaming:](https://github.com/TippingGame/F8Framework/blob/main/Launcher/FF8.cs)Module customization renaming.[FF8.cs](https://github.com/TippingGame/F8Framework/blob/main/Launcher/FF8.cs) diff --git a/Runtime/ExcelTool/ReadExcel.cs b/Runtime/ExcelTool/ReadExcel.cs index 1f8933c..8d8c45d 100644 --- a/Runtime/ExcelTool/ReadExcel.cs +++ b/Runtime/ExcelTool/ReadExcel.cs @@ -87,7 +87,10 @@ public void LoadAllExcelData() Serialize(container, temp, each.Value); objs.Add(each.Key, container); } - F8DataManager.Instance.RuntimeLoadAll(objs); + string _class = "F8DataManager"; + string method= "RuntimeLoadAll"; + object[] parameters = new object[] { objs }; + Util.Assembly.InvokeMethod(_class, method, parameters); LogF8.LogConfig("运行时导表成功!"); } diff --git a/Runtime/Launcher/GameLauncher.cs b/Runtime/Launcher/GameLauncher.cs deleted file mode 100644 index 48ab920..0000000 --- a/Runtime/Launcher/GameLauncher.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System.Collections; -using F8Framework.Core; -using UnityEngine; - -public class GameLauncher : MonoBehaviour -{ - IEnumerator Start() - { - // 初始化模块中心 - ModuleCenter.Initialize(this); - - // 初始化版本 - FF8.HotUpdate = ModuleCenter.CreateModule(); - - // 按顺序创建模块,可按需添加 - FF8.Message = ModuleCenter.CreateModule(); - FF8.Input = ModuleCenter.CreateModule(new DefaultInputHelper()); - FF8.Storage = ModuleCenter.CreateModule(); - FF8.Timer = ModuleCenter.CreateModule(); - FF8.Procedure = ModuleCenter.CreateModule(); - FF8.Network = ModuleCenter.CreateModule(); - FF8.FSM = ModuleCenter.CreateModule(); - FF8.GameObjectPool = ModuleCenter.CreateModule(); - FF8.Asset = ModuleCenter.CreateModule(); - // yield return AssetBundleManager.Instance.LoadAssetBundleManifest(); // WebGL专用 - FF8.Config = ModuleCenter.CreateModule(); - FF8.Audio = ModuleCenter.CreateModule(); - FF8.Tween = ModuleCenter.CreateModule(); - FF8.UI = ModuleCenter.CreateModule(); - // yield return F8DataManager.Instance.LoadLocalizedStringsIEnumerator(); // WebGL专用 - FF8.Local = ModuleCenter.CreateModule(); - FF8.SDK = ModuleCenter.CreateModule(); - FF8.Download = ModuleCenter.CreateModule(); - FF8.LogWriter = ModuleCenter.CreateModule(); - - StartGame(); - yield break; - } - - // 开始游戏 - public void StartGame() - { - - } - - void Update() - { - // 更新模块 - ModuleCenter.Update(); - } - - void LateUpdate() - { - // 更新模块 - ModuleCenter.LateUpdate(); - } - - void FixedUpdate() - { - // 更新模块 - ModuleCenter.FixedUpdate(); - } -} diff --git a/Runtime/Localization/Core/Localization.cs b/Runtime/Localization/Core/Localization.cs index baf1a4a..db26f6c 100644 --- a/Runtime/Localization/Core/Localization.cs +++ b/Runtime/Localization/Core/Localization.cs @@ -1,8 +1,8 @@ using System; +using System.Collections; using System.Collections.Generic; using System.Linq; using System.Reflection; -using F8Framework.F8ExcelDataClass; using UnityEngine; namespace F8Framework.Core @@ -20,8 +20,7 @@ public class Localization : ModuleSingleton, IModule public string CurrentLanguageName { get; set; } // 当前语言索引 public int CurrentLanguageIndex => GetLanguageIndex(CurrentLanguageName); - - private LocalizedStrings p_LocalizedStrings; + public void OnInit(object createParam) { Load(); @@ -42,13 +41,13 @@ public void Load(bool force = false) #if UNITY_EDITOR if (Application.isPlaying) { - F8DataManager.Instance.LoadLocalizedStrings(); + Util.Assembly.InvokeMethod("F8DataManager", "LoadLocalizedStrings", new object[] { }); } else { try { - F8DataManager.Instance.GetLocalizedStrings(); + Util.Assembly.InvokeMethod("F8DataManager", "GetLocalizedStrings", new object[] { }); } catch { @@ -60,7 +59,7 @@ public void Load(bool force = false) LogF8.LogConfig("由于WebGL异步加载完本地化表,请在创建本地化模块之前加上:yield return F8DataManager.Instance.LoadLocalizedStringsIEnumerator();"); LoadSuccess(); #else - F8DataManager.Instance.LoadLocalizedStrings(); + Util.Assembly.InvokeMethod("F8DataManager", "LoadLocalizedStrings", new object[] { }); LoadSuccess(); #endif @@ -68,22 +67,42 @@ public void Load(bool force = false) private void LoadSuccess() { - Dictionary tb = F8DataManager.Instance.GetLocalizedStrings(); + var tb = Util.Assembly.InvokeMethod("F8DataManager", "GetLocalizedStrings", new object[] { }) as IDictionary; LogF8.LogConfig("获取本地化表格成功!"); foreach (var item in tb.Values) { - if(item.TextID == null) + // 反射获取 TextID 属性的值 + Type itemType = item.GetType(); + FieldInfo textIDProperty = itemType.GetField("TextID"); + if (textIDProperty == null) + { + LogF8.LogError("无法获取 TextID 属性,请检查对象类型。"); + continue; + } + + object textIDValue = textIDProperty.GetValue(item); + if (textIDValue == null) { continue; } + + string id = string.Empty; + FieldInfo idProperty = itemType.GetField("id"); + object idValue = idProperty?.GetValue(item); + if (idProperty != null && idValue != null) + { + id = idValue.ToString(); + } + string textID = textIDValue.ToString(); + List list = new List(); - + Type type2 = item.GetType(); FieldInfo[] fields = type2.GetFields(); - + foreach (var field in fields) { // 排除 id 和 TextID 字段 @@ -93,6 +112,7 @@ private void LoadSuccess() { LanguageList.Add(field.Name); } + object value = field.GetValue(item); // 这里传递的是 item 对象 if (value != null) { @@ -102,20 +122,22 @@ private void LoadSuccess() { // 如果字段的值为 null,你可以选择添加一个默认值,或者进行其他处理 list.Add(""); - LogF8.LogConfig($"本地化表字段:\"{item.TextID}\" 的值为空"); + LogF8.LogConfig($"本地化表id:\"{id}\",字段:\"{textID}\" 的值为空"); } } } - if (LocalizedStrings.ContainsKey(item.TextID)) + + if (LocalizedStrings.ContainsKey(textID)) { - LogF8.LogError($"本地化表 ID \"{item.TextID}\" 出现重复,请修改。"); + LogF8.LogError($"本地化表id:\"{id}\",字段:\"{textID}\" 出现重复,请修改。"); continue; } - LocalizedStrings.TryAdd(item.TextID, list); - } - LocalizationSettings.LoadLanguageSettings(); - ChangeLanguage(CurrentLanguageName ?? ""); + LocalizedStrings.TryAdd(textID, list); + + LocalizationSettings.LoadLanguageSettings(); + ChangeLanguage(CurrentLanguageName ?? ""); + } } /// diff --git a/Runtime/Utility/Assembly.cs b/Runtime/Utility/Assembly.cs index c6295eb..7a30901 100644 --- a/Runtime/Utility/Assembly.cs +++ b/Runtime/Utility/Assembly.cs @@ -955,6 +955,40 @@ public static MethodInfo[] GetAssemblyMethodsByAttribute(System.Reflection.As return methodSet.ToArray(); } + /// + /// 执行方法 + /// + /// 类名 + /// 方法名 + /// 方法参数 + /// 返回值 + public static object InvokeMethod(string className, string methodName, object[] parameters = null) + { + // 查找指定类名的类型 + var type = domainAssemblies.SelectMany(assembly => assembly.GetTypes()).FirstOrDefault(t => t.Name == className); + if (type == null) + { + throw new Exception($"需要检查是否有正确生成{className}类!"); + } + + // 获取单例的实例 + var property = type.BaseType?.GetProperty("Instance", BindingFlags.Public | BindingFlags.Static); + if (property == null) + { + throw new Exception($"无法获取 {className} 的单例实例!"); + } + var instance = property.GetValue(null, null); + + // 获取方法并执行 + var method = type.GetMethod(methodName, BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic); + if (method == null) + { + throw new Exception($"类中 : {type} 找不到此方法 : {methodName}!"); + } + + return method.Invoke(instance, parameters); + } + /// /// 执行方法; /// @@ -1184,7 +1218,7 @@ public static Type GetInterfaceHigestImplementedType(Type derivedType, Type inte /// 名称数组 public static string[] GetTypeAllFields() { - return GetTypeAllFields(typeof(T)); + return GetTypeAllString(typeof(T)); } /// @@ -1192,13 +1226,25 @@ public static string[] GetTypeAllFields() /// /// type类型 /// 名称数组 - public static string[] GetTypeAllFields(Type type) + public static string[] GetTypeAllString(Type type) { var fields = type.GetFields(BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Static); return fields.Select(f => f.Name).ToArray(); } + /// + /// 获取类Type类型中的所有字段名; + /// + /// type类型 + /// 名称数组 + public static System.Reflection.FieldInfo[] GetTypeAllFields(Type type) + { + var fields = type.GetFields(BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic | + BindingFlags.Static); + return fields.Select(f => f).ToArray(); + } + /// /// 获取Type类型中所有属性字段名; /// diff --git a/Tests/AssetManager/DemoAssetManager.cs b/Tests/AssetManager/DemoAssetManager.cs index badca37..5c9098b 100644 --- a/Tests/AssetManager/DemoAssetManager.cs +++ b/Tests/AssetManager/DemoAssetManager.cs @@ -1,5 +1,6 @@ using System.Collections; using F8Framework.Core; +using F8Framework.Launcher; using UnityEngine; namespace F8Framework.Tests diff --git a/Tests/Audio/DemoAudio.cs b/Tests/Audio/DemoAudio.cs index cd45a63..2aa61b0 100644 --- a/Tests/Audio/DemoAudio.cs +++ b/Tests/Audio/DemoAudio.cs @@ -1,4 +1,5 @@ using F8Framework.Core; +using F8Framework.Launcher; using UnityEngine; using UnityEngine.Audio; diff --git a/Tests/Download/DemoDownload.cs b/Tests/Download/DemoDownload.cs index 7aec2d3..3ee3906 100644 --- a/Tests/Download/DemoDownload.cs +++ b/Tests/Download/DemoDownload.cs @@ -1,6 +1,7 @@ using System; using System.IO; using F8Framework.Core; +using F8Framework.Launcher; using UnityEngine; namespace F8Framework.Tests diff --git a/Tests/Event/DemoMessageManager.cs b/Tests/Event/DemoMessageManager.cs index c996b2f..1bda373 100644 --- a/Tests/Event/DemoMessageManager.cs +++ b/Tests/Event/DemoMessageManager.cs @@ -1,4 +1,5 @@ using F8Framework.Core; +using F8Framework.Launcher; using UnityEngine; namespace F8Framework.Tests diff --git a/Tests/ExcelTool/DemoExcelTool.cs b/Tests/ExcelTool/DemoExcelTool.cs index 165da73..a3e18d8 100644 --- a/Tests/ExcelTool/DemoExcelTool.cs +++ b/Tests/ExcelTool/DemoExcelTool.cs @@ -2,38 +2,38 @@ using System.Collections.Generic; using UnityEngine; using F8Framework.Core; -using F8Framework.F8ExcelDataClass; +// using F8Framework.F8ExcelDataClass; namespace F8Framework.Tests { public class DemoExcelTool : MonoBehaviour { // 方式一:读取二进制或者json - IEnumerator Start() - { - // 同步加载全部配置 - FF8.Config.LoadAll(); - - foreach (var item in FF8.Config.LoadAllAsync()) // 异步加载全部配置 - { - yield return item; - } - - // 单个表单个数据 - LogF8.Log(FF8.Config.GetSheet1ByID(2).name); - - // 单个表全部数据 - foreach (var item in FF8.Config.GetSheet1()) - { - LogF8.Log(item.Key); - LogF8.Log(item.Value.name); - } - - // 指定名字加载 - Sheet1 sheet1 = new Sheet1(); - sheet1 = FF8.Config.Load("Sheet1"); - LogF8.Log(sheet1.Dict[2].name); - } + // IEnumerator Start() + // { + // // 同步加载全部配置 + // FF8.Config.LoadAll(); + // + // foreach (var item in FF8.Config.LoadAllAsync()) // 异步加载全部配置 + // { + // yield return item; + // } + // + // // 单个表单个数据 + // LogF8.Log(FF8.Config.GetSheet1ByID(2).name); + // + // // 单个表全部数据 + // foreach (var item in FF8.Config.GetSheet1()) + // { + // LogF8.Log(item.Key); + // LogF8.Log(item.Value.name); + // } + // + // // 指定名字加载 + // Sheet1 sheet1 = new Sheet1(); + // sheet1 = FF8.Config.Load("Sheet1"); + // LogF8.Log(sheet1.Dict[2].name); + // } // // 方式二:运行时读取Excel // IEnumerator Start() diff --git a/Tests/F8Framework.Tests.asmdef b/Tests/F8Framework.Tests.asmdef index 1bbd194..ed0e9ab 100644 --- a/Tests/F8Framework.Tests.asmdef +++ b/Tests/F8Framework.Tests.asmdef @@ -4,15 +4,19 @@ "references": [ "F8Framework.Core", "Unity.Timeline", - "SimpleWebTransport" + "SimpleWebTransport", + "F8Framework.F8ExcelDataClass", + "F8Framework.Launcher" ], "includePlatforms": [], "excludePlatforms": [], "allowUnsafeCode": false, "overrideReferences": false, "precompiledReferences": [], - "autoReferenced": true, - "defineConstraints": [], + "autoReferenced": false, + "defineConstraints": [ + "BUILD_F8FRAMEWORK_TEST" + ], "versionDefines": [], "noEngineReferences": false } \ No newline at end of file diff --git a/Tests/FSM/DemoFSM.cs b/Tests/FSM/DemoFSM.cs index 3c76293..811ab73 100644 --- a/Tests/FSM/DemoFSM.cs +++ b/Tests/FSM/DemoFSM.cs @@ -1,5 +1,6 @@ using UnityEngine; using F8Framework.Core; +using F8Framework.Launcher; namespace F8Framework.Tests { diff --git a/Tests/GameObjectPool/DemoGameObjectPool.cs b/Tests/GameObjectPool/DemoGameObjectPool.cs index e6de8eb..5d89817 100644 --- a/Tests/GameObjectPool/DemoGameObjectPool.cs +++ b/Tests/GameObjectPool/DemoGameObjectPool.cs @@ -1,5 +1,6 @@ using UnityEngine; using F8Framework.Core; +using F8Framework.Launcher; namespace F8Framework.Tests { diff --git a/Tests/HotUpdateManager/DemoHotUpdateManager.cs b/Tests/HotUpdateManager/DemoHotUpdateManager.cs index 2146bd9..74aad33 100644 --- a/Tests/HotUpdateManager/DemoHotUpdateManager.cs +++ b/Tests/HotUpdateManager/DemoHotUpdateManager.cs @@ -2,6 +2,7 @@ using System.Collections; using System.Collections.Generic; using F8Framework.Core; +using F8Framework.Launcher; using UnityEngine; namespace F8Framework.Tests diff --git a/Tests/HybridCLR/README.md b/Tests/HybridCLR/README.md index f3c9eba..c003f2b 100644 --- a/Tests/HybridCLR/README.md +++ b/Tests/HybridCLR/README.md @@ -8,27 +8,64 @@ 接入HybridCLR热更新代码组件。 1. 使用这个[官方教程](https://hybridclr.doc.code-philosophy.com/docs/beginner/quickstart)创建HotUpdate程序集后。 2. 找到代码[F8Helper.cs](https://github.com/TippingGame/F8Framework/blob/main/Editor/F8Helper/F8Helper.cs) - 1.解除注释状态 - * [MenuItem("开发工具/生成并复制热更新Dll-F8")] - public static void GenerateCopyHotUpdateDll() - { - // HybridCLR.Editor.Commands.PrebuildCommand.GenerateAll(); - // FileTools.SafeClearDir(Application.dataPath + "/AssetBundles/Code"); - // FileTools.CheckDirAndCreateWhenNeeded(Application.dataPath + "/AssetBundles/Code"); - // List hotUpdateDll = new List() - // { - // "HotUpdate", // 自行添加需要热更的程序集 - // }; - // foreach (var dll in hotUpdateDll) - // { - // FileTools.SafeCopyFile( - // HybridCLR.Editor.SettingsUtil.GetHotUpdateDllsOutputDirByTarget(EditorUserBuildSettings.activeBuildTarget) + "/" + dll + ".dll", - // Application.dataPath + "/AssetBundles/Code/" + dll + ".bytes"); - // LogF8.LogAsset("生成并复制热更新dll:" + dll); - // } - // AssetDatabase.Refresh(); - } + * 解除注释状态 +```C# + [MenuItem("开发工具/生成并复制热更新Dll-F8")] + public static void GenerateCopyHotUpdateDll() + { + // HybridCLR.Editor.Commands.PrebuildCommand.GenerateAll(); + // FileTools.SafeClearDir(Application.dataPath + "/AssetBundles/Code"); + // FileTools.CheckDirAndCreateWhenNeeded(Application.dataPath + "/AssetBundles/Code"); + // List hotUpdateDll = new List() + // { + // "F8Framework.F8ExcelDataClass", // 自行添加需要热更的程序集 + // "F8Framework.Launcher" + // }; + // foreach (var dll in hotUpdateDll) + // { + // FileTools.SafeCopyFile( + // HybridCLR.Editor.SettingsUtil.GetHotUpdateDllsOutputDirByTarget(EditorUserBuildSettings.activeBuildTarget) + "/" + dll + ".dll", + // Application.dataPath + "/AssetBundles/Code/" + dll + ".bytes"); + // LogF8.LogAsset("生成并复制热更新dll:" + dll); + // } + // AssetDatabase.Refresh(); + } +``` +3. 代码已拆分程序集 + * AOT程序集:(F8Framework.Core) + * 热更新程序集:(F8Framework.F8ExcelDataClass、F8Framework.Launcher) +4. 注意:主工程不能直接引用热更新代码,这里通过反射来调用热更新代码。 + * 在启动场景挂在一个加载dll脚本 +```C# +using System; +using System.Linq; +using System.Reflection; +using UnityEngine; +public class LoadDll : MonoBehaviour +{ + public void Start() + { + // Editor环境下,HotUpdate.dll.bytes已经被自动加载,不需要加载,重复加载反而会出问题。 +#if !UNITY_EDITOR + AssetBundle bundle1 = AssetBundle.LoadFromFile(AssetBundleHelper.GetAssetBundlePath() + "code/F8Framework.F8ExcelDataClass"); + TextAsset asset1 = bundle1.LoadAsset("f8framework.f8exceldataclass"); + Assembly hotUpdateAss1 = Assembly.Load(asset1.bytes); + AssetBundle bundle2 = AssetBundle.LoadFromFile(AssetBundleHelper.GetAssetBundlePath() + "code/F8Framework.Launcher"); + TextAsset asset2 = bundle2.LoadAsset("f8framework.launcher"); + Assembly hotUpdateAss2 = Assembly.Load(asset2.bytes); +#else + // Editor下无需加载,直接查找获得HotUpdate程序集 + Assembly hotUpdateAss = System.AppDomain.CurrentDomain.GetAssemblies().First(a => a.GetName().Name == "F8Framework.F8ExcelDataClass"); + Assembly hotUpdateAss2 = System.AppDomain.CurrentDomain.GetAssemblies().First(a => a.GetName().Name == "F8Framework.Launcher"); +#endif + Type type = hotUpdateAss2.GetType("F8Framework.Launcher.GameLauncher"); + // 添加组件 + gameObject.AddComponent(type); + } +} + +``` ## 导入插件(需要首先导入HybridCLR) 注意!HybridCLR:https://github.com/focus-creative-games/hybridclr_unity.git 方式一:直接下载文件,放入Unity diff --git a/Tests/HybridCLR/README_EN.md b/Tests/HybridCLR/README_EN.md index f3c9eba..57dd797 100644 --- a/Tests/HybridCLR/README_EN.md +++ b/Tests/HybridCLR/README_EN.md @@ -1,34 +1,71 @@ # F8 接入HybridCLR -[![license](http://img.shields.io/badge/license-MIT-green.svg)](https://opensource.org/licenses/MIT) -[![Unity Version](https://img.shields.io/badge/unity-2021.3.15f1-blue)](https://unity.com) -[![Platform](https://img.shields.io/badge/platform-Win%20%7C%20Android%20%7C%20iOS%20%7C%20Mac%20%7C%20Linux%20%7C%20WebGL-orange)]() +[![license](http://img.shields.io/badge/license-MIT-green.svg)](https://opensource.org/licenses/MIT) +[![Unity Version](https://img.shields.io/badge/unity-2021.3.15f1-blue)](https://unity.com) +[![Platform](https://img.shields.io/badge/platform-Win%20%7C%20Android%20%7C%20iOS%20%7C%20Mac%20%7C%20Linux%20%7C%20WebGL-orange)]() ## 简介(希望自己点击F8,就能开始制作游戏,不想多余的事) 接入HybridCLR热更新代码组件。 -1. 使用这个[官方教程](https://hybridclr.doc.code-philosophy.com/docs/beginner/quickstart)创建HotUpdate程序集后。 -2. 找到代码[F8Helper.cs](https://github.com/TippingGame/F8Framework/blob/main/Editor/F8Helper/F8Helper.cs) - 1.解除注释状态 - * [MenuItem("开发工具/生成并复制热更新Dll-F8")] - public static void GenerateCopyHotUpdateDll() - { - // HybridCLR.Editor.Commands.PrebuildCommand.GenerateAll(); - // FileTools.SafeClearDir(Application.dataPath + "/AssetBundles/Code"); - // FileTools.CheckDirAndCreateWhenNeeded(Application.dataPath + "/AssetBundles/Code"); - // List hotUpdateDll = new List() - // { - // "HotUpdate", // 自行添加需要热更的程序集 - // }; - // foreach (var dll in hotUpdateDll) - // { - // FileTools.SafeCopyFile( - // HybridCLR.Editor.SettingsUtil.GetHotUpdateDllsOutputDirByTarget(EditorUserBuildSettings.activeBuildTarget) + "/" + dll + ".dll", - // Application.dataPath + "/AssetBundles/Code/" + dll + ".bytes"); - // LogF8.LogAsset("生成并复制热更新dll:" + dll); - // } - // AssetDatabase.Refresh(); - } +1. 使用这个[官方教程](https://hybridclr.doc.code-philosophy.com/docs/beginner/quickstart)创建HotUpdate程序集后。 +2. 找到代码[F8Helper.cs](https://github.com/TippingGame/F8Framework/blob/main/Editor/F8Helper/F8Helper.cs) + * 解除注释状态 +```C# + [MenuItem("开发工具/生成并复制热更新Dll-F8")] + public static void GenerateCopyHotUpdateDll() + { + // HybridCLR.Editor.Commands.PrebuildCommand.GenerateAll(); + // FileTools.SafeClearDir(Application.dataPath + "/AssetBundles/Code"); + // FileTools.CheckDirAndCreateWhenNeeded(Application.dataPath + "/AssetBundles/Code"); + // List hotUpdateDll = new List() + // { + // "F8Framework.F8ExcelDataClass", // 自行添加需要热更的程序集 + // "F8Framework.Launcher" + // }; + // foreach (var dll in hotUpdateDll) + // { + // FileTools.SafeCopyFile( + // HybridCLR.Editor.SettingsUtil.GetHotUpdateDllsOutputDirByTarget(EditorUserBuildSettings.activeBuildTarget) + "/" + dll + ".dll", + // Application.dataPath + "/AssetBundles/Code/" + dll + ".bytes"); + // LogF8.LogAsset("生成并复制热更新dll:" + dll); + // } + // AssetDatabase.Refresh(); + } +``` +3. 代码已拆分程序集 + * AOT程序集:(F8Framework.Core) + * 热更新程序集:(F8Framework.F8ExcelDataClass、F8Framework.Launcher) +4. 注意:主工程不能直接引用热更新代码,这里通过反射来调用热更新代码。 + * 在启动场景挂在一个加载dll脚本 +```C# +using System; +using System.Linq; +using System.Reflection; +using UnityEngine; +public class LoadDll : MonoBehaviour +{ + public void Start() + { + // Editor环境下,HotUpdate.dll.bytes已经被自动加载,不需要加载,重复加载反而会出问题。 +#if !UNITY_EDITOR + AssetBundle bundle1 = AssetBundle.LoadFromFile(AssetBundleHelper.GetAssetBundlePath() + "code/F8Framework.F8ExcelDataClass"); + TextAsset asset1 = bundle1.LoadAsset("f8framework.f8exceldataclass"); + Assembly hotUpdateAss1 = Assembly.Load(asset1.bytes); + AssetBundle bundle2 = AssetBundle.LoadFromFile(AssetBundleHelper.GetAssetBundlePath() + "code/F8Framework.Launcher"); + TextAsset asset2 = bundle2.LoadAsset("f8framework.launcher"); + Assembly hotUpdateAss2 = Assembly.Load(asset2.bytes); +#else + // Editor下无需加载,直接查找获得HotUpdate程序集 + Assembly hotUpdateAss = System.AppDomain.CurrentDomain.GetAssemblies().First(a => a.GetName().Name == "F8Framework.F8ExcelDataClass"); + Assembly hotUpdateAss2 = System.AppDomain.CurrentDomain.GetAssemblies().First(a => a.GetName().Name == "F8Framework.Launcher"); +#endif + Type type = hotUpdateAss2.GetType("F8Framework.Launcher.GameLauncher"); + // 添加组件 + gameObject.AddComponent(type); + } +} + +``` ## 导入插件(需要首先导入HybridCLR) 注意!HybridCLR:https://github.com/focus-creative-games/hybridclr_unity.git 方式一:直接下载文件,放入Unity diff --git a/Tests/Input/DemoInput.cs b/Tests/Input/DemoInput.cs index 8dc3a5a..bd98458 100644 --- a/Tests/Input/DemoInput.cs +++ b/Tests/Input/DemoInput.cs @@ -1,5 +1,6 @@ using System; using F8Framework.Core; +using F8Framework.Launcher; using UnityEngine; namespace F8Framework.Tests diff --git a/Tests/Localization/Example/Scripts/LanguageCycler.cs b/Tests/Localization/Example/Scripts/LanguageCycler.cs index 4e20ec0..796d67b 100644 --- a/Tests/Localization/Example/Scripts/LanguageCycler.cs +++ b/Tests/Localization/Example/Scripts/LanguageCycler.cs @@ -1,11 +1,14 @@ -using F8Framework.Core; +using System.Collections; +using F8Framework.Core; +using F8Framework.F8ExcelDataClass; +using F8Framework.Launcher; using UnityEngine; namespace F8Framework.Tests { public class LanguageCycler : MonoBehaviour { - private void Start() + IEnumerator Start() { // 初始化模块中心 ModuleCenter.Initialize(this); @@ -33,6 +36,7 @@ private void Start() FF8.SDK = ModuleCenter.CreateModule(); FF8.Download = ModuleCenter.CreateModule(); FF8.LogWriter = ModuleCenter.CreateModule(); + yield break; } void Update() diff --git a/Tests/Log/DemoF8Log.cs b/Tests/Log/DemoF8Log.cs index 09a92e0..6ef6477 100644 --- a/Tests/Log/DemoF8Log.cs +++ b/Tests/Log/DemoF8Log.cs @@ -1,4 +1,5 @@ using F8Framework.Core; +using F8Framework.Launcher; using UnityEngine; namespace F8Framework.Tests diff --git a/Tests/Network/MultiNetworkChannel/MultiNetworkClient.cs b/Tests/Network/MultiNetworkChannel/MultiNetworkClient.cs index 7c45b32..38f1d6f 100644 --- a/Tests/Network/MultiNetworkChannel/MultiNetworkClient.cs +++ b/Tests/Network/MultiNetworkChannel/MultiNetworkClient.cs @@ -1,6 +1,7 @@ using System.Text; using UnityEngine; using F8Framework.Core; +using F8Framework.Launcher; using UnityEngine.UI; namespace F8Framework.Tests diff --git a/Tests/Network/MultiNetworkChannel/MultiNetworkServer.cs b/Tests/Network/MultiNetworkChannel/MultiNetworkServer.cs index 542e430..a5ac683 100644 --- a/Tests/Network/MultiNetworkChannel/MultiNetworkServer.cs +++ b/Tests/Network/MultiNetworkChannel/MultiNetworkServer.cs @@ -2,6 +2,7 @@ using UnityEngine; using UnityEngine.UI; using F8Framework.Core; +using F8Framework.Launcher; namespace F8Framework.Tests { diff --git a/Tests/Procedure/DemoProcedure.cs b/Tests/Procedure/DemoProcedure.cs index d80e5d3..5a6742c 100644 --- a/Tests/Procedure/DemoProcedure.cs +++ b/Tests/Procedure/DemoProcedure.cs @@ -1,4 +1,5 @@ using F8Framework.Core; +using F8Framework.Launcher; using UnityEngine; namespace F8Framework.Tests diff --git a/Tests/SDKManager/DemoSDK.cs b/Tests/SDKManager/DemoSDK.cs index 02748fe..4bb8ab4 100644 --- a/Tests/SDKManager/DemoSDK.cs +++ b/Tests/SDKManager/DemoSDK.cs @@ -1,4 +1,5 @@ using F8Framework.Core; +using F8Framework.Launcher; using UnityEngine; namespace F8Framework.Tests diff --git a/Tests/Storage/DemoStorage.cs b/Tests/Storage/DemoStorage.cs index 303ff19..e07cad9 100644 --- a/Tests/Storage/DemoStorage.cs +++ b/Tests/Storage/DemoStorage.cs @@ -1,5 +1,6 @@ using System; using F8Framework.Core; +using F8Framework.Launcher; using UnityEngine; namespace F8Framework.Tests diff --git a/Tests/Timer/DemoF8Timer.cs b/Tests/Timer/DemoF8Timer.cs index dde1270..d4e8264 100644 --- a/Tests/Timer/DemoF8Timer.cs +++ b/Tests/Timer/DemoF8Timer.cs @@ -1,4 +1,5 @@ using F8Framework.Core; +using F8Framework.Launcher; using UnityEngine; namespace F8Framework.Tests diff --git a/Tests/UI/DemoUIManager.cs b/Tests/UI/DemoUIManager.cs index 36c7047..7bd9e41 100644 --- a/Tests/UI/DemoUIManager.cs +++ b/Tests/UI/DemoUIManager.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using F8Framework.Core; +using F8Framework.Launcher; using UnityEngine; namespace F8Framework.Tests diff --git a/link.xml b/link.xml index 61c558f..a123906 100644 --- a/link.xml +++ b/link.xml @@ -15,6 +15,7 @@ - + + \ No newline at end of file diff --git a/package.json b/package.json index 33524d2..cb046d9 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "com.tippinggame.f8framework", "displayName": "F8Framework", "description": "Unity F8Framework Core", - "version": "1.0.16", + "version": "1.0.17", "unity": "2021.3", "license": "MIT", "keywords": ["Unity", "Framework", "Core"],