This commit is contained in:
2026-06-12 17:12:29 +08:00
49 changed files with 389 additions and 1009 deletions
@@ -1,110 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 468a46d0ae32c3544b7d98094e6448a9, type: 3}
m_Name: AddressableAssetSettings
m_EditorClassIdentifier:
m_DefaultGroup: a45d0d25213104f44ad8fe07eb3548d1
m_currentHash:
serializedVersion: 2
Hash: 24f7d451677154961ad4235510acee73
m_OptimizeCatalogSize: 0
m_BuildRemoteCatalog: 0
m_BundleLocalCatalog: 0
m_CatalogRequestsTimeout: 0
m_DisableCatalogUpdateOnStart: 0
m_IgnoreUnsupportedFilesInBuild: 0
m_UniqueBundleIds: 0
m_NonRecursiveBuilding: 1
m_CCDEnabled: 0
m_maxConcurrentWebRequests: 3
m_ContiguousBundles: 1
m_StripUnityVersionFromBundleBuild: 0
m_DisableVisibleSubAssetRepresentations: 0
m_ShaderBundleNaming: 0
m_ShaderBundleCustomNaming:
m_MonoScriptBundleNaming: 0
m_CheckForContentUpdateRestrictionsOption: 0
m_MonoScriptBundleCustomNaming:
m_RemoteCatalogBuildPath:
m_Id:
m_RemoteCatalogLoadPath:
m_Id:
m_ContentStateBuildPathProfileVariableName:
m_CustomContentStateBuildPath:
m_ContentStateBuildPath:
m_BuildAddressablesWithPlayerBuild: 0
m_overridePlayerVersion: '[UnityEditor.PlayerSettings.bundleVersion]'
m_GroupAssets:
- {fileID: 11400000, guid: 902fafad9bba93345b7a8d95737094ff, type: 2}
- {fileID: 11400000, guid: 0835c4975fed7d14795ec925b54bca80, type: 2}
m_BuildSettings:
m_CompileScriptsInVirtualMode: 0
m_CleanupStreamingAssetsAfterBuilds: 1
m_LogResourceManagerExceptions: 1
m_BundleBuildPath: Temp/com.unity.addressables/AssetBundles
m_ProfileSettings:
m_Profiles:
- m_InheritedParent:
m_Id: 70f0db63e1b2ccc49a35826b26d42ffa
m_ProfileName: Default
m_Values:
- m_Id: 693c6cc232ba75944b76340184d8d5da
m_Value: '{UnityEngine.AddressableAssets.Addressables.RuntimePath}/[BuildTarget]'
- m_Id: 6c2c4720f61c8134b9b4b2c9776cd752
m_Value: http://[PrivateIpAddress]:[HostingServicePort]
- m_Id: 6e2463dd44eb1f54cb6bd7d1ed217d78
m_Value: '[UnityEngine.AddressableAssets.Addressables.BuildPath]/[BuildTarget]'
- m_Id: 79ac92be39ae3b548acfff4d617e9f3d
m_Value: ServerData/[BuildTarget]
- m_Id: c213fc96596f0424b92d9b5da98dc49d
m_Value: '[UnityEditor.EditorUserBuildSettings.activeBuildTarget]'
m_ProfileEntryNames:
- m_Id: 693c6cc232ba75944b76340184d8d5da
m_Name: Local.LoadPath
m_InlineUsage: 0
- m_Id: 6c2c4720f61c8134b9b4b2c9776cd752
m_Name: Remote.LoadPath
m_InlineUsage: 0
- m_Id: 6e2463dd44eb1f54cb6bd7d1ed217d78
m_Name: Local.BuildPath
m_InlineUsage: 0
- m_Id: 79ac92be39ae3b548acfff4d617e9f3d
m_Name: Remote.BuildPath
m_InlineUsage: 0
- m_Id: c213fc96596f0424b92d9b5da98dc49d
m_Name: BuildTarget
m_InlineUsage: 0
m_ProfileVersion: 1
m_LabelTable:
m_LabelNames:
- default
- config
m_SchemaTemplates: []
m_GroupTemplateObjects:
- {fileID: 11400000, guid: e3717cb91779b3c42b0fa261a19e2089, type: 2}
m_InitializationObjects: []
m_CertificateHandlerType:
m_AssemblyName:
m_ClassName:
m_ActivePlayerDataBuilderIndex: 3
m_DataBuilders:
- {fileID: 11400000, guid: e3793cbe36022934c8e448ba864e7d23, type: 2}
- {fileID: 11400000, guid: c1b22d2e9c442004aa8ce9415342d39b, type: 2}
- {fileID: 11400000, guid: 09b58a3e361fb894bb05487b13037296, type: 2}
- {fileID: 11400000, guid: 451c87b652b66324b93ed04ca22c9f79, type: 2}
m_ActiveProfileId: 70f0db63e1b2ccc49a35826b26d42ffa
m_HostingServicesManager:
m_HostingServiceInfos: []
m_Settings: {fileID: 11400000}
m_NextInstanceId: 0
m_RegisteredServiceTypeRefs: []
m_PingTimeoutInMilliseconds: 5000
@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: e60983ba8459aa349988c3ecb65abf31
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 820198255c53d7944a20b1c68c5aa2c9
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: f800864c27698964ab1fae5a1384670e
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 0da0bb3855501354a9bc91673adc7b14
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -1,76 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1a3c5d64ac83548c09dd1678b9f6f1cd, type: 3}
m_Name: Packed Assets
m_EditorClassIdentifier:
m_SchemaObjects:
- {fileID: 5467363252551928993}
- {fileID: 56619259277380849}
m_Description: Pack assets into asset bundles.
m_Settings: {fileID: 11400000, guid: e60983ba8459aa349988c3ecb65abf31, type: 2}
--- !u!114 &56619259277380849
MonoBehaviour:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5834b5087d578d24c926ce20cd31e6d6, type: 3}
m_Name: ContentUpdateGroupSchema
m_EditorClassIdentifier:
m_Group: {fileID: 0}
m_StaticContent: 0
--- !u!114 &5467363252551928993
MonoBehaviour:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e5d17a21594effb4e9591490b009e7aa, type: 3}
m_Name: BundledAssetGroupSchema
m_EditorClassIdentifier:
m_Group: {fileID: 0}
m_InternalBundleIdMode: 1
m_Compression: 1
m_IncludeAddressInCatalog: 1
m_IncludeGUIDInCatalog: 1
m_IncludeLabelsInCatalog: 1
m_InternalIdNamingMode: 0
m_CacheClearBehavior: 0
m_IncludeInBuild: 1
m_BundledAssetProviderType:
m_AssemblyName:
m_ClassName:
m_ForceUniqueProvider: 0
m_UseAssetBundleCache: 1
m_UseAssetBundleCrc: 1
m_UseAssetBundleCrcForCachedBundles: 1
m_UseUWRForLocalBundles: 0
m_Timeout: 0
m_ChunkedTransfer: 0
m_RedirectLimit: -1
m_RetryCount: 0
m_BuildPath:
m_Id:
m_LoadPath:
m_Id:
m_BundleMode: 0
m_AssetBundleProviderType:
m_AssemblyName:
m_ClassName:
m_BundleNaming: 0
m_AssetLoadMode: 0
@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: e3717cb91779b3c42b0fa261a19e2089
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 0177e9cd130f2644c94ff6f27591f32f
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -1,23 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bbb281ee3bf0b054c82ac2347e9e782c, type: 3}
m_Name: Built In Data
m_EditorClassIdentifier:
m_GroupName: Built In Data
m_Data:
m_SerializedData: []
m_GUID: cd4decefa4232884fa80ecdbff31c3a5
m_SerializeEntries: []
m_ReadOnly: 1
m_Settings: {fileID: 11400000, guid: e60983ba8459aa349988c3ecb65abf31, type: 2}
m_SchemaSet:
m_Schemas: []
@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 0835c4975fed7d14795ec925b54bca80
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
@@ -1,31 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bbb281ee3bf0b054c82ac2347e9e782c, type: 3}
m_Name: Default Local Group
m_EditorClassIdentifier:
m_GroupName: Default Local Group
m_Data:
m_SerializedData: []
m_GUID: a45d0d25213104f44ad8fe07eb3548d1
m_SerializeEntries:
- m_GUID: 2286bdb9423d4da48ba3b1bd8765173f
m_Address: Assets/Configs
m_ReadOnly: 0
m_SerializedLabels:
- config
FlaggedDuringContentUpdateRestriction: 0
m_ReadOnly: 0
m_Settings: {fileID: 11400000, guid: e60983ba8459aa349988c3ecb65abf31, type: 2}
m_SchemaSet:
m_Schemas:
- {fileID: 11400000, guid: a6c2bb9206a787d40a5ddd394de13ea2, type: 2}
- {fileID: 11400000, guid: 38bec3dff28f2014194d6df27120ffe2, type: 2}
@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 902fafad9bba93345b7a8d95737094ff
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: a65b9c2fafd9b444aa0ce2c532b4133d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -1,17 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b1487f5d688e4f94f828f879d599dbdc, type: 3}
m_Name: Built In Data_PlayerDataGroupSchema
m_EditorClassIdentifier:
m_Group: {fileID: 11400000, guid: 0835c4975fed7d14795ec925b54bca80, type: 2}
m_IncludeResourcesFolders: 1
m_IncludeBuildSettingsScenes: 1
@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 20981212fe0549c4f8f7200e0ce3f519
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
@@ -1,45 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e5d17a21594effb4e9591490b009e7aa, type: 3}
m_Name: Default Local Group_BundledAssetGroupSchema
m_EditorClassIdentifier:
m_Group: {fileID: 0}
m_InternalBundleIdMode: 1
m_Compression: 1
m_IncludeAddressInCatalog: 1
m_IncludeGUIDInCatalog: 1
m_IncludeLabelsInCatalog: 1
m_InternalIdNamingMode: 0
m_CacheClearBehavior: 0
m_IncludeInBuild: 1
m_BundledAssetProviderType:
m_AssemblyName: Unity.ResourceManager, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
m_ClassName: UnityEngine.ResourceManagement.ResourceProviders.BundledAssetProvider
m_ForceUniqueProvider: 0
m_UseAssetBundleCache: 1
m_UseAssetBundleCrc: 1
m_UseAssetBundleCrcForCachedBundles: 1
m_UseUWRForLocalBundles: 0
m_Timeout: 0
m_ChunkedTransfer: 0
m_RedirectLimit: -1
m_RetryCount: 0
m_BuildPath:
m_Id: 6e2463dd44eb1f54cb6bd7d1ed217d78
m_LoadPath:
m_Id: 693c6cc232ba75944b76340184d8d5da
m_BundleMode: 0
m_AssetBundleProviderType:
m_AssemblyName: Unity.ResourceManager, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
m_ClassName: UnityEngine.ResourceManagement.ResourceProviders.AssetBundleProvider
m_BundleNaming: 0
m_AssetLoadMode: 0
@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: a6c2bb9206a787d40a5ddd394de13ea2
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
@@ -1,16 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5834b5087d578d24c926ce20cd31e6d6, type: 3}
m_Name: Default Local Group_ContentUpdateGroupSchema
m_EditorClassIdentifier:
m_Group: {fileID: 0}
m_StaticContent: 0
@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 38bec3dff28f2014194d6df27120ffe2
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 72553237eae78744ba2ff551ec768030
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -1,20 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 88d21199f5d473f4db36845f2318f180, type: 3}
m_Name: BuildScriptFastMode
m_EditorClassIdentifier:
instanceProviderType:
m_AssemblyName: Unity.ResourceManager, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
m_ClassName: UnityEngine.ResourceManagement.ResourceProviders.InstanceProvider
sceneProviderType:
m_AssemblyName: Unity.ResourceManager, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
m_ClassName: UnityEngine.ResourceManagement.ResourceProviders.SceneProvider
@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: e3793cbe36022934c8e448ba864e7d23
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
@@ -1,20 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3e2e0ffa088c91d41a086d0b8cb16bdc, type: 3}
m_Name: BuildScriptPackedMode
m_EditorClassIdentifier:
instanceProviderType:
m_AssemblyName: Unity.ResourceManager, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
m_ClassName: UnityEngine.ResourceManagement.ResourceProviders.InstanceProvider
sceneProviderType:
m_AssemblyName: Unity.ResourceManager, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
m_ClassName: UnityEngine.ResourceManagement.ResourceProviders.SceneProvider
@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 451c87b652b66324b93ed04ca22c9f79
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
@@ -1,20 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ad8c280d42ee0ed41a27db23b43dd2bf, type: 3}
m_Name: BuildScriptPackedPlayMode
m_EditorClassIdentifier:
instanceProviderType:
m_AssemblyName: Unity.ResourceManager, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
m_ClassName: UnityEngine.ResourceManagement.ResourceProviders.InstanceProvider
sceneProviderType:
m_AssemblyName: Unity.ResourceManager, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
m_ClassName: UnityEngine.ResourceManagement.ResourceProviders.SceneProvider
@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 09b58a3e361fb894bb05487b13037296
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
@@ -1,20 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bb0e4994b34add1409fd8ccaf4a82de5, type: 3}
m_Name: BuildScriptVirtualMode
m_EditorClassIdentifier:
instanceProviderType:
m_AssemblyName: Unity.ResourceManager, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
m_ClassName: UnityEngine.ResourceManagement.ResourceProviders.InstanceProvider
sceneProviderType:
m_AssemblyName: Unity.ResourceManager, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
m_ClassName: UnityEngine.ResourceManagement.ResourceProviders.SceneProvider
@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: c1b22d2e9c442004aa8ce9415342d39b
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
@@ -1,15 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3a189bb168d8d90478a09ea08c2f3d72, type: 3}
m_Name: DefaultObject
m_EditorClassIdentifier:
m_AddressableAssetSettingsGuid: e60983ba8459aa349988c3ecb65abf31
@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 5f9b9b19ab849a34f8c66956df64c186
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
@@ -1,34 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7e3976da977cb49238499ea3b4c237ae, type: 3}
m_Name: ProfileDataSourceSettings
m_EditorClassIdentifier:
profileGroupTypes:
- m_GroupTypePrefix: Built-In
m_Variables:
- m_Suffix: BuildPath
m_Value: '[UnityEngine.AddressableAssets.Addressables.BuildPath]/[BuildTarget]'
- m_Suffix: LoadPath
m_Value: '{UnityEngine.AddressableAssets.Addressables.RuntimePath}/[BuildTarget]'
- m_GroupTypePrefix: Editor Hosted
m_Variables:
- m_Suffix: BuildPath
m_Value: ServerData/[BuildTarget]
- m_Suffix: LoadPath
m_Value: http://[PrivateIpAddress]:[HostingServicePort]
environments: []
currentEnvironment:
id:
projectId:
projectGenesisId:
name:
isDefault: 0
@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 59f7c3bb2d35146c88dfedf2004a8ae7
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
-8
View File
@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: fed1a435d3956452d953a0a0118be7b1
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 56a8814c396664b048814cc6d477d82d
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+1 -1
View File
@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 2286bdb9423d4da48ba3b1bd8765173f
guid: 410e26deedfc5864bb5bd6b9cad1f450
folderAsset: yes
DefaultImporter:
externalObjects: {}
@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 692a8563bf4ba9749905419c982657c8
guid: 2286bdb9423d4da48ba3b1bd8765173f
folderAsset: yes
DefaultImporter:
externalObjects: {}
@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 7ba7c6a75110f483683dc4885aee0758
guid: f8c67570025fefa448706dadc37c5988
TextScriptImporter:
externalObjects: {}
userData:
@@ -1,188 +0,0 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using SGModule.Common.Helper;
using UnityEditor;
using UnityEditor.PackageManager;
using UnityEditor.PackageManager.Requests;
using PackageInfo = UnityEditor.PackageManager.PackageInfo;
#if USE_ADDRESSABLES
using UnityEditor.AddressableAssets;
#endif
namespace SGModule.Editor {
[InitializeOnLoad]
public static class AddressablesManager {
private const string AddressablesPackageName = "com.unity.addressables";
private const string AddressablesSymbol = "USE_ADDRESSABLES";
private static AddRequest _addRequest;
// 安装标记,避免重复弹窗
private static bool _isInstallingAddressables;
static AddressablesManager() {
EditorApplication.projectChanged += OnProjectChanged; // 监听项目变更
CheckAndSetupAddressables();
}
private static string DefaultConfigsPath => "Assets/Configs"; // 默认的 Addressables 配置路径
private static void CheckAndSetupAddressables() {
if (IsAddressablesInstalled()) {
Log.Info("ConfigLoader", "Addressables 已安装,正在初始化...");
AddScriptingDefineSymbol(AddressablesSymbol);
#if USE_ADDRESSABLES
EnsureAddressablesConfigured();
#endif
}
else {
RemoveScriptingDefineSymbol(AddressablesSymbol);
if (!_isInstallingAddressables) {
PromptToInstallAddressables();
}
}
}
private static bool IsAddressablesInstalled() {
return PackageInfo.GetAllRegisteredPackages().Any(package => package.name == AddressablesPackageName);
}
private static void PromptToInstallAddressables() {
var install = EditorUtility.DisplayDialog(
"Addressables 未安装",
"当前插件依赖 Addressables 功能,请安装以确保正常使用。\n\n是否立即安装 Addressables",
"安装",
"取消");
if (install) {
InstallAddressables();
}
else {
Log.Warning("ConfigLoader", "用户取消安装 Addressables,部分功能可能无法正常使用!");
}
}
private static void InstallAddressables() {
if (_isInstallingAddressables) {
return; // 防止重复安装
}
Log.Info("ConfigLoader", "开始安装 Addressables...");
_isInstallingAddressables = true; // 标记正在安装,避免重复弹窗
_addRequest = Client.Add(AddressablesPackageName);
EditorApplication.update += MonitorAddRequest;
}
private static void MonitorAddRequest() {
if (_addRequest == null || !_addRequest.IsCompleted) {
return;
}
EditorApplication.update -= MonitorAddRequest;
if (_addRequest.Status == StatusCode.Success) {
Log.Info("ConfigLoader", "Addressables 安装成功!");
EditorUtility.DisplayDialog("安装完成", "Addressables 安装成功,请稍候等待 Unity 刷新。", "确定");
CheckAndSetupAddressables();
}
else if (_addRequest.Status >= StatusCode.Failure) {
Log.Error("ConfigLoader", $"安装 Addressables 失败:{_addRequest.Error.message}");
EditorUtility.DisplayDialog("安装失败", $"安装 Addressables 失败:{_addRequest.Error.message}", "确定");
}
_isInstallingAddressables = false; // 重置标记
}
private static void AddScriptingDefineSymbol(string symbol) {
var symbols = new List<string>(PlayerSettings
.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup).Split(';'));
if (symbols.Contains(symbol)) {
return;
}
symbols.Add(symbol);
PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup,
string.Join(";", symbols));
Log.Info("ConfigLoader", $"已添加脚本定义符号: {symbol}");
}
private static void RemoveScriptingDefineSymbol(string symbol) {
var symbols = new List<string>(PlayerSettings
.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup).Split(';'));
if (symbols.Contains(symbol)) {
symbols.Remove(symbol);
PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup,
string.Join(";", symbols));
Log.Info("ConfigLoader", $"已移除脚本定义符号: {symbol}");
}
}
private static void OnProjectChanged() {
Log.Info("ConfigLoader", "检测到项目变更,重新检查 Addressables 状态...");
CheckAndSetupAddressables();
}
#if USE_ADDRESSABLES
private static void EnsureAddressablesConfigured() {
var settings = AddressableAssetSettingsDefaultObject.Settings;
if (settings == null) {
Log.Info("ConfigLoader", "正在初始化 Addressables 设置...");
settings = AddressableAssetSettingsDefaultObject.GetSettings(true); // 自动创建配置
}
// 确保默认的 Configs 文件夹存在并被添加到 Addressables
var needRefresh = false;
if (!Directory.Exists(DefaultConfigsPath)) {
Directory.CreateDirectory(DefaultConfigsPath);
Log.Info("ConfigLoader", $"已创建文件夹: {DefaultConfigsPath}");
needRefresh = true;
}
if (!IsFolderInAddressables(DefaultConfigsPath)) {
var guid = AssetDatabase.AssetPathToGUID(DefaultConfigsPath);
var group = settings.DefaultGroup;
settings.CreateOrMoveEntry(guid, group)?.SetLabel("config", true, true);
needRefresh = true;
}
if (needRefresh) {
AssetDatabase.Refresh();
}
}
private static bool IsFolderInAddressables(string folderPath) {
var settings = AddressableAssetSettingsDefaultObject.Settings;
foreach (var group in settings.groups)
{
if (group)
{
foreach (var entry in group.entries)
{
if (AssetDatabase.GUIDToAssetPath(entry.guid) == folderPath)
{
return true;
}
}
}
}
return false;
}
#endif
}
}
@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 383ac67f695b4c6e94ba988c9303cd5b
timeCreated: 1733734050
@@ -3,8 +3,10 @@ using System.IO;
using SGModule.Common.Helper;
using UnityEngine;
namespace SGModule.ConfigLoader {
public class ConfigFileManager {
namespace SGModule.ConfigLoader
{
public class ConfigFileManager
{
private const int MaxErrorCount = 6;
private const string ConfigFileNameKey = "ConfigFileName";
private const string FirstLaunchKey = "FirstLaunch";
@@ -15,44 +17,59 @@ namespace SGModule.ConfigLoader {
private static bool IsFirstLaunch => !PlayerPrefs.HasKey(FirstLaunchKey);
private static string SavedConfigFileName => PlayerPrefs.GetString(ConfigFileNameKey);
private static void SetFirstLaunch() {
private static void SetFirstLaunch()
{
PlayerPrefs.SetInt(FirstLaunchKey, 1);
}
private static void SetSavedConfigFileName(string name) {
private static void SetSavedConfigFileName(string name)
{
PlayerPrefs.SetString(ConfigFileNameKey, name);
}
private void IncrementErrorCount() {
private void IncrementErrorCount()
{
_initConfigErrorCount++;
}
// 检查是否需要下载新配置,基于传入的期望配置文件名setting
private static bool HasNewConfig(string expectedSetting) {
if (string.IsNullOrEmpty(SavedConfigFileName)) {
private static bool HasNewConfig(string expectedSetting)
{
if (string.IsNullOrEmpty(SavedConfigFileName))
{
return true;
}
return !SavedConfigFileName.Equals(expectedSetting);
}
private void FirstLaunchCopyConfig(Action<bool> callback) {
private void FirstLaunchCopyConfig(Action<bool> callback)
{
SetFirstLaunch();
FileNetworkManager.Instance.CopyStreamingAssetsToPersistentDataPath(result => {
Debug.Log("000000000000000000000000000000");
FileNetworkManager.Instance.CopyStreamingAssetsToPersistentDataPath(result =>
{
Debug.Log("0000000000000000000000000000006");
var isSuccess = false;
if (result) {
if (result)
{
Debug.Log("0000000000000000000000000000007");
var names = FileNetworkManager.Instance.GetFileNamesFromPersistentDataPath(FileNetworkManager.FolderName);
if (names.Length > 0) {
if (names.Length > 0)
{
Debug.Log("0000000000000000000000000000008");
Debug.Log("0000000000000000000000000000009"+names[0]);
SetSavedConfigFileName(names[0]);
isSuccess = true;
}
}
else {
else
{
Log.ConfigLoader.Error("拷贝文件失败 请检查Configs文件夹是否有配置文件");
}
if (!isSuccess) {
if (!isSuccess)
{
IncrementErrorCount();
}
@@ -60,16 +77,20 @@ namespace SGModule.ConfigLoader {
});
}
private void DownloadConfig(string cdnUrl, string setting, Action<bool, string> callback) {
private void DownloadConfig(string cdnUrl, string setting, Action<bool, string> callback)
{
var url = $"{cdnUrl}/config/{setting}";
Log.ConfigLoader.Info($"开始下载配置文件 {url}", false);
FileNetworkManager.Instance.ReadData(url, result => {
if (!string.IsNullOrEmpty(result)) {
FileNetworkManager.Instance.ReadData(url, result =>
{
if (!string.IsNullOrEmpty(result))
{
SetSavedConfigFileName(setting);
FileNetworkManager.Instance.WriteToPersistentData(FileNetworkManager.Instance.GetConfigFOlderPath(), setting, result);
callback?.Invoke(true, result);
}
else {
else
{
Log.ConfigLoader.Error("下载配置文件失败");
IncrementErrorCount();
callback?.Invoke(false, null);
@@ -77,40 +98,92 @@ namespace SGModule.ConfigLoader {
});
}
private void ReadLocalConfig(Action<bool, string> callback) {
private void ReadLocalConfig(Action<bool, string> callback)
{
var savedCfgName = SavedConfigFileName;
Log.ConfigLoader.Info($"开始读取本地配置文件 {savedCfgName}", false);
if (string.IsNullOrEmpty(savedCfgName)) {
if (string.IsNullOrEmpty(savedCfgName))
{
IncrementErrorCount();
callback?.Invoke(false, null);
return;
}
var path = Path.Combine(FileNetworkManager.Instance.GetConfigFOlderPath(), savedCfgName);
FileNetworkManager.Instance.ReadData(path, result => {
if (!string.IsNullOrEmpty(result)) {
bool have_config = false;
if (Directory.Exists(FileNetworkManager.Instance.GetConfigFOlderPath()))
{
// 获取该目录下的所有文件
string[] files = Directory.GetFiles(FileNetworkManager.Instance.GetConfigFOlderPath());
if (files.Length > 0)
{
Debug.Log("文件夹下有文件");
have_config = true;
}
else
{
Debug.Log("文件夹为空");
}
}
else
{
Debug.Log("文件夹不存在");
}
if (have_config)
{
FileNetworkManager.Instance.ReadData(path, result =>
{
if (!string.IsNullOrEmpty(result))
{
callback?.Invoke(true, result);
}
else {
else
{
Log.ConfigLoader.Error("读取本地数据异常");
IncrementErrorCount();
callback?.Invoke(false, null);
}
});
}
else
{
Debug.Log(savedCfgName);
FirstLaunchCopyConfig(success =>
{
path = Path.Combine(FileNetworkManager.Instance.GetConfigFOlderPath(), SavedConfigFileName);
FileNetworkManager.Instance.ReadData(path, result =>
{
if (!string.IsNullOrEmpty(result))
{
callback?.Invoke(true, result);
}
});
});
}
}
/// <summary>
/// 配置文件检查与加载流程
/// </summary>
public void CheckAndLoadConfig(ConfigInitOptions initOptions, Action<string> onConfigLoaded, Action<ConfigLoaderState> callback) {
if (HasExceededMaxErrors) {
public void CheckAndLoadConfig(ConfigInitOptions initOptions, Action<string> onConfigLoaded, Action<ConfigLoaderState> callback)
{
if (HasExceededMaxErrors)
{
callback?.Invoke(ConfigLoaderState.Failed);
return;
}
if (IsFirstLaunch) {
FirstLaunchCopyConfig(success => {
if (!success) {
Debug.Log("是否第一次登录"+IsFirstLaunch);
if (IsFirstLaunch)
{
FirstLaunchCopyConfig(success =>
{
if (!success)
{
IncrementErrorCount();
}
@@ -118,18 +191,25 @@ namespace SGModule.ConfigLoader {
});
return;
}
if (HasNewConfig(initOptions.Setting)) {
DownloadConfig(initOptions.CdnUrl, initOptions.Setting, (success, json) => {
if (success) {
Debug.Log("是否需要下载"+HasNewConfig(initOptions.Setting));
if (HasNewConfig(initOptions.Setting))
{
DownloadConfig(initOptions.CdnUrl, initOptions.Setting, (success, json) =>
{
if (success)
{
ReloadConfig(json, onConfigLoaded, callback);
}
else {
ReadLocalConfig((readSuccess, localJson) => {
if (readSuccess) {
else
{
ReadLocalConfig((readSuccess, localJson) =>
{
if (readSuccess)
{
ReloadConfig(localJson, onConfigLoaded, callback);
}
else {
else
{
callback?.Invoke(ConfigLoaderState.Failed);
}
});
@@ -138,13 +218,18 @@ namespace SGModule.ConfigLoader {
return;
}
ReadLocalConfig((success, json) => {
if (success) {
ReadLocalConfig((success, json) =>
{
if (success)
{
ReloadConfig(json, onConfigLoaded, callback);
}
else {
FirstLaunchCopyConfig(result => {
if (!result) {
else
{
FirstLaunchCopyConfig(result =>
{
if (!result)
{
IncrementErrorCount();
}
@@ -154,8 +239,10 @@ namespace SGModule.ConfigLoader {
});
}
private static void ReloadConfig(string json, Action<string> onConfigLoaded, Action<ConfigLoaderState> callback) {
if (string.IsNullOrWhiteSpace(json)) {
private static void ReloadConfig(string json, Action<string> onConfigLoaded, Action<ConfigLoaderState> callback)
{
if (string.IsNullOrWhiteSpace(json))
{
callback?.Invoke(ConfigLoaderState.JsonEmptyError);
return;
}
@@ -6,9 +6,9 @@ using System.Linq;
using SGModule.Common.Base;
using SGModule.Common.Helper;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;
using UnityEngine.ResourceManagement.AsyncOperations;
using System.Threading.Tasks;
#if UNITY_EDITOR
using UnityEditor;
#endif
@@ -16,42 +16,53 @@ using UnityEditor;
#if USE_ADDRESSABLES
#endif
namespace SGModule.ConfigLoader {
public class FileNetworkManager : SingletonMonoBehaviour<FileNetworkManager> {
namespace SGModule.ConfigLoader
{
public class FileNetworkManager : SingletonMonoBehaviour<FileNetworkManager>
{
public const string FolderName = "Configs";
private const string FolderLabel = "config";
private string _configFolderPath;
protected override void Awake() {
protected override void Awake()
{
base.Awake();
_configFolderPath = Path.Combine(Application.persistentDataPath, FolderName);
}
public string GetConfigFOlderPath() {
public string GetConfigFOlderPath()
{
return _configFolderPath;
}
// 示例解析文件列表方法(你可以根据实际需求实现)
private List<string> ParseFileList(string data) {
private List<string> ParseFileList(string data)
{
// 假设 data 是文件列表的文本,解析文件名
// 根据实际情况解析,例如通过换行符分割
return data.Split(new[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries).ToList();
}
public void CopyStreamingAssetsToPersistentDataPath(Action<bool> onComplete = null) {
public void CopyStreamingAssetsToPersistentDataPath(Action<bool> onComplete = null)
{
Debug.Log("0000000000000000000000000000001");
// 如果目标文件夹不存在,创建它
if (!Directory.Exists(_configFolderPath)) {
if (!Directory.Exists(_configFolderPath))
{
Directory.CreateDirectory(_configFolderPath);
}
Debug.Log("0000000000000000000000000000002");
// CopyFile(onComplete);
StartCoroutine(CopyFile(onComplete));
}
private void HandleInitializationError() {
private void HandleInitializationError()
{
// 检查文件是否存在
var path = $"{Application.dataPath}/Library/com.unity.addressables/aa/Android/settings.json";
if (!File.Exists(path)) {
if (!File.Exists(path))
{
Log.ConfigLoader.Warning(
$"Settings file not found at: {path}. Rebuilding Addressables may be required.");
}
@@ -60,68 +71,104 @@ namespace SGModule.ConfigLoader {
// 提示用户或执行其他逻辑
// 比如:显示弹窗或退出程序
}
private IEnumerator CopyFile(Action<bool> onComplete = null)
{
Debug.Log("开始加载 Configs 文件夹");
private IEnumerator CopyFile(Action<bool> onComplete = null) {
#if USE_ADDRESSABLES
var handle = Addressables.LoadResourceLocationsAsync(FolderLabel);
TextAsset[] files = Resources.LoadAll<TextAsset>("Configs");
yield return handle;
if (files.Length > 0)
{
TextAsset jsonFile = files[0];
string jsonFileName = jsonFile.name;
if (handle.Status == AsyncOperationStatus.Succeeded) {
// 查找以 ".json" 结尾的文件
var jsonLocation = handle.Result.FirstOrDefault(loc => loc.PrimaryKey.EndsWith(".json"));
if (jsonLocation != null) {
var jsonFileName = Path.GetFileName(jsonLocation.PrimaryKey);
// 加载 JSON 文件
var textAssetAsync = Addressables.LoadAssetAsync<TextAsset>(jsonLocation);
yield return textAssetAsync;
if (textAssetAsync.Status == AsyncOperationStatus.Succeeded) {
var jsonFile = textAssetAsync.Result;
Log.ConfigLoader.Info($"Loaded JSON Name:{jsonFileName} content: " + jsonFile.text);
if (!Directory.Exists(_configFolderPath))
Directory.CreateDirectory(_configFolderPath);
var destFilePath = Path.Combine(_configFolderPath, jsonFileName);
var destFilePath = Path.Combine(_configFolderPath, jsonFileName + ".json");
// 同步写入文件
File.WriteAllBytes(destFilePath, jsonFile.bytes);
// 等待一帧再执行回调,保持协程风格
yield return null;
onComplete?.Invoke(true);
}
else {
Log.ConfigLoader.Error("Failed to load JSON file");
else
{
Log.ConfigLoader.Error("Resources/Configs 下没有找到任何 TextAsset 文件");
yield return null;
onComplete?.Invoke(false);
}
}
else {
Log.ConfigLoader.Error("No JSON file found in folder");
// private IEnumerable CopyFile(Action<bool> onComplete = null)
// {
onComplete?.Invoke(false);
}
}
else {
Log.ConfigLoader.Error("Failed to load folder resources");
onComplete?.Invoke(false);
}
#else
Log.Error( "没有 Addressables 插件,请检查 ");
yield break;
#endif
}
// // if (handle.Status == AsyncOperationStatus.Succeeded) {
// // 查找以 ".json" 结尾的文件
// // var jsonLocation = handle.Result.FirstOrDefault(loc => loc.PrimaryKey.EndsWith(".json"));
private IEnumerator CopyFile(string sourceFile, string destFile, Action<bool> onComplete = null) {
// // if (jsonLocation != null) {
// // var jsonFileName = Path.GetFileName(jsonLocation.PrimaryKey);
// // 加载 JSON 文件
// // var textAssetAsync = Addressables.LoadAssetAsync<TextAsset>(jsonLocation);
// Debug.Log("0000000000000000000000000000003");
// TextAsset[] files = Resources.LoadAll<TextAsset>("Configs");
// // yield return textAssetAsync;
// // if (textAssetAsync.Status == AsyncOperationStatus.Succeeded)
// // {
// TextAsset jsonFile = files[0];
// string jsonFileName = jsonFile.name;
// Log.ConfigLoader.Info($"Loaded JSON Name:{jsonFileName} content: " + jsonFile.text);
// Debug.Log("0000000000000000000000000000004");
// var destFilePath = Path.Combine(_configFolderPath, jsonFileName);
// File.WriteAllBytes(destFilePath, jsonFile.bytes);
// Debug.Log("0000000000000000000000000000005");
// onComplete?.Invoke(true);
// // }
// // else {
// // Log.ConfigLoader.Error("Failed to load JSON file");
// // onComplete?.Invoke(false);
// // }
// // }
// // else {
// // Log.ConfigLoader.Error("No JSON file found in folder");
// // onComplete?.Invoke(false);
// // }
// // }
// // else
// // {
// // Log.ConfigLoader.Error("Failed to load folder resources");
// // onComplete?.Invoke(false);
// // }
// }
private IEnumerator CopyFile(string sourceFile, string destFile, Action<bool> onComplete = null)
{
var filePath = "file://" + sourceFile;
using (var www = UnityWebRequest.Get(filePath)) {
using (var www = UnityWebRequest.Get(filePath))
{
yield return www.SendWebRequest();
if (www.result == UnityWebRequest.Result.Success) {
if (www.result == UnityWebRequest.Result.Success)
{
File.WriteAllBytes(destFile, www.downloadHandler.data);
Log.ConfigLoader.Info($"File copied to {destFile}");
onComplete?.Invoke(true);
}
else {
else
{
Log.ConfigLoader.Error("Failed to copy file: " + www.error);
onComplete?.Invoke(false);
@@ -134,7 +181,8 @@ namespace SGModule.ConfigLoader {
/// </summary>
/// <param name="path"></param>
/// <param name="callback"></param>
public void ReadData(string path, Action<string> callback) {
public void ReadData(string path, Action<string> callback)
{
StartCoroutine(ReadDataEnumerator(path, callback));
}
@@ -144,14 +192,17 @@ namespace SGModule.ConfigLoader {
/// <param name="path"></param>
/// <param name="callback"></param>
/// <returns></returns>
private IEnumerator ReadDataEnumerator(string path, Action<string> callback) {
private IEnumerator ReadDataEnumerator(string path, Action<string> callback)
{
string fullPath;
// 判断是网络URL还是本地文件路径
if (path.StartsWith("http://") || path.StartsWith("https://")) {
if (path.StartsWith("http://") || path.StartsWith("https://"))
{
fullPath = path; // 网络URL
#if UNITY_EDITOR
if (path.StartsWith("http://") && PlayerSettings.insecureHttpOption == InsecureHttpOption.NotAllowed) {
if (path.StartsWith("http://") && PlayerSettings.insecureHttpOption == InsecureHttpOption.NotAllowed)
{
Log.ConfigLoader.Error("发起了 HTTP 链接,但设置了不允许非Https连接,请检查设置!!!");
callback?.Invoke(null);
@@ -159,22 +210,26 @@ namespace SGModule.ConfigLoader {
}
#endif
}
else {
else
{
// 本地文件路径
fullPath = "file://" + path;
}
Debug.Log(fullPath);
// 使用UnityWebRequest读取数据
using (var webRequest = UnityWebRequest.Get(fullPath)) {
using (var webRequest = UnityWebRequest.Get(fullPath))
{
yield return webRequest.SendWebRequest();
if (webRequest.result == UnityWebRequest.Result.ConnectionError ||
webRequest.result == UnityWebRequest.Result.ProtocolError) {
webRequest.result == UnityWebRequest.Result.ProtocolError)
{
Log.ConfigLoader.Error($"Error while reading file: {webRequest.error} path: {fullPath}");
callback?.Invoke(null); // 返回null表示出错
}
else {
else
{
var data = webRequest.downloadHandler.text;
callback?.Invoke(data); // 通过回调传出数据
}
@@ -187,18 +242,21 @@ namespace SGModule.ConfigLoader {
/// <param name="folderName">文件夹名称</param>
/// <param name="fileName">文件名称</param>
/// <param name="content">要写入的内容</param>
public void WriteToPersistentData(string folderName, string fileName, string content) {
public void WriteToPersistentData(string folderName, string fileName, string content)
{
// 获取持久化数据路径
var folderPath = Path.Combine(Application.persistentDataPath, folderName);
// 如果文件夹不存在,则创建它
if (!Directory.Exists(folderPath)) {
if (!Directory.Exists(folderPath))
{
Directory.CreateDirectory(folderPath);
}
// 删除原有文件
var existingFiles = Directory.GetFiles(folderPath);
foreach (var file in existingFiles) {
foreach (var file in existingFiles)
{
File.Delete(file);
}
@@ -217,7 +275,8 @@ namespace SGModule.ConfigLoader {
/// </summary>
/// <param name="subdirectory"></param>
/// <returns></returns>
public string[] GetFileNamesFromPersistentDataPath(string subdirectory) {
public string[] GetFileNamesFromPersistentDataPath(string subdirectory)
{
var directoryPath = Path.Combine(Application.persistentDataPath, subdirectory);
if (Directory.Exists(directoryPath))
@@ -7,20 +7,24 @@ using SGModule.Common.Helper;
using UnityEngine;
using UnityEngine.Networking;
namespace SGModule.Net {
public enum ConnectionStatus {
namespace SGModule.Net
{
public enum ConnectionStatus
{
Uninitialized, // 未初始化
Connected, // 已连接
Disconnected // 未连接
}
// 网络检测类
public class NetChecker : SingletonMonoBehaviour<NetChecker> {
public class NetChecker : SingletonMonoBehaviour<NetChecker>
{
private const float WebRequestInterval = 5f;
private const float PingInterval = 2;
// 可配置多个检测 URL
[SerializeField] private List<string> checkUrls = new() {
[SerializeField]
private List<string> checkUrls = new() {
"https://www.baidu.com", // 国内 URL
"https://www.google.com" // 国外 URL
};
@@ -45,16 +49,19 @@ namespace SGModule.Net {
/// <summary>
/// null = 未检测;true = 联网;false = 未联网
/// </summary>
private bool? IsConnected {
private bool? IsConnected
{
get;
set;
}
private void OnEnable() {
private void OnEnable()
{
StartCheckingInternet();
}
private void OnDisable() {
private void OnDisable()
{
StopCheckingInternet();
}
@@ -64,69 +71,84 @@ namespace SGModule.Net {
/// <param name="timeout">最多等待的总时间(秒)</param>
/// <param name="checkInterval">每次重试间隔</param>
/// <param name="callback">检测结果回调</param>
public IEnumerator WaitUntilNetworkConnected(float timeout, float checkInterval, Action<bool> callback) {
public IEnumerator WaitUntilNetworkConnected(float timeout, float checkInterval, Action<bool> callback)
{
var elapsed = 0f;
// 阶段 1: 等待初始化完成
while (!IsConnected.HasValue && elapsed < timeout) {
while (!IsConnected.HasValue && elapsed < timeout)
{
yield return new WaitForSeconds(checkInterval);
elapsed += checkInterval;
}
if (!IsConnected.HasValue) {
if (!IsConnected.HasValue)
{
Log.Net.Warning("网络检测初始化超时!");
callback(false);
yield break;
}
// 阶段 2: 等待网络恢复
while (IsConnected == false && elapsed < timeout) {
while (IsConnected == false && elapsed < timeout)
{
Log.Net.Warning($"网络异常,等待中... 已耗时: {elapsed:F1}s");
yield return new WaitForSeconds(checkInterval);
elapsed += checkInterval;
}
var success = IsConnected == true;
if (!success) {
if (!success)
{
Log.Net.Warning("网络连接等待超时!");
}
callback(success);
}
public ConnectionStatus GetConnectionStatus() {
return IsConnected switch {
public ConnectionStatus GetConnectionStatus()
{
return IsConnected switch
{
null => ConnectionStatus.Uninitialized,
true => ConnectionStatus.Connected,
false => ConnectionStatus.Disconnected
};
}
public void Init() {
public void Init()
{
StartCheckingInternet();
}
private void StartCheckingInternet() {
private void StartCheckingInternet()
{
_checkInterval = usePingCheck ? PingInterval : WebRequestInterval;
_checkInternetCoroutine ??= StartCoroutine(CheckInternetRoutine());
}
private void StopCheckingInternet() {
if (_checkInternetCoroutine != null) {
private void StopCheckingInternet()
{
if (_checkInternetCoroutine != null)
{
StopCoroutine(_checkInternetCoroutine);
_checkInternetCoroutine = null;
}
}
private IEnumerator CheckInternetRoutine() {
while (true) {
if (_isChecking) {
private IEnumerator CheckInternetRoutine()
{
while (true)
{
if (_isChecking)
{
yield break; // 避免并发冲突
}
_isChecking = true;
if (QuickNetDeviceCheck()) {
if (QuickNetDeviceCheck())
{
// if (usePingCheck) {
yield return CheckWithPing();
// }
@@ -134,11 +156,13 @@ namespace SGModule.Net {
// yield return CheckWithUnityWebRequest();
// }
}
else {
else
{
IsConnected = false;
}
if (IsConnected.HasValue && _lastConnected != IsConnected.Value) {
if (IsConnected.HasValue && _lastConnected != IsConnected.Value)
{
Log.Net.Info($"网络状态变化: {IsConnected}");
_lastConnected = IsConnected.Value;
}
@@ -151,42 +175,46 @@ namespace SGModule.Net {
/// <summary>
/// 使用 Ping 检测网络连通性
/// </summary>
private IEnumerator CheckWithPing() {
private IEnumerator CheckWithPing()
{
var pings = _pingAddresses.Select(ip => new Ping(ip)).ToList();
var startTime = Time.realtimeSinceStartup;
var success = false;
// 等待所有 Ping 返回结果或超时
while (Time.realtimeSinceStartup - startTime < _checkInterval) {
foreach (var ping in pings) {
if (ping.isDone && ping.time >= 0) {
success = true;
break;
}
}
// // 等待所有 Ping 返回结果或超时
// while (Time.realtimeSinceStartup - startTime < _checkInterval) {
// foreach (var ping in pings) {
// if (ping.isDone && ping.time >= 0) {
// success = true;
// break;
// }
// }
if (success) {
break;
}
// if (success) {
// break;
// }
// }
yield return new WaitForSecondsRealtime(0.1f);
}
// 如果有任意一个 Ping 成功,网络即为可用
IsConnected = success;
IsConnected = true;
}
/// <summary>
/// 使用 UnityWebRequest 检测网络连通性
/// </summary>
private IEnumerator CheckWithUnityWebRequest() {
if (!string.IsNullOrEmpty(_preferredUrl)) {
private IEnumerator CheckWithUnityWebRequest()
{
if (!string.IsNullOrEmpty(_preferredUrl))
{
var request = UnityWebRequest.Get(_preferredUrl);
request.timeout = (int)_checkInterval;
yield return request.SendWebRequest();
if (request.result == UnityWebRequest.Result.Success) {
if (request.result == UnityWebRequest.Result.Success)
{
IsConnected = true;
request.Dispose();
yield break;
@@ -202,7 +230,8 @@ namespace SGModule.Net {
var ops = new List<UnityWebRequestAsyncOperation>();
var requests = new List<UnityWebRequest>();
foreach (var url in checkUrls) {
foreach (var url in checkUrls)
{
var req = UnityWebRequest.Get(url);
req.timeout = (int)_checkInterval;
ops.Add(req.SendWebRequest());
@@ -211,16 +240,20 @@ namespace SGModule.Net {
yield return StartCoroutine(WaitForAnyRequest(ops));
foreach (var req in requests) {
foreach (var req in requests)
{
req.Dispose();
}
}
// 等待任意一个请求完成并返回
private IEnumerator WaitForAnyRequest(List<UnityWebRequestAsyncOperation> ops) {
while (ops.Any(op => !op.isDone)) {
if (ops.Any(op => op.isDone && op.webRequest.result == UnityWebRequest.Result.Success)) {
private IEnumerator WaitForAnyRequest(List<UnityWebRequestAsyncOperation> ops)
{
while (ops.Any(op => !op.isDone))
{
if (ops.Any(op => op.isDone && op.webRequest.result == UnityWebRequest.Result.Success))
{
break;
}
@@ -229,8 +262,10 @@ namespace SGModule.Net {
var successOp = ops.FirstOrDefault(op => op.webRequest.result == UnityWebRequest.Result.Success);
if (successOp == null) {
foreach (var op in ops.Where(op => op.isDone)) {
if (successOp == null)
{
foreach (var op in ops.Where(op => op.isDone))
{
Log.Net.Warning($"请求失败: {op.webRequest.url}, 错误: {op.webRequest.error}");
}
}
@@ -240,32 +275,41 @@ namespace SGModule.Net {
}
// 添加或删除检查 URL
public void AddCheckUrl(string url) {
if (!checkUrls.Contains(url)) {
public void AddCheckUrl(string url)
{
if (!checkUrls.Contains(url))
{
checkUrls.Add(url);
}
}
public void RemoveCheckUrl(string url) {
if (checkUrls.Contains(url)) {
public void RemoveCheckUrl(string url)
{
if (checkUrls.Contains(url))
{
checkUrls.Remove(url);
}
}
public void AddPingTarget(string ip) {
if (!_pingAddresses.Contains(ip)) {
public void AddPingTarget(string ip)
{
if (!_pingAddresses.Contains(ip))
{
_pingAddresses.Add(ip);
}
}
public void RemovePingTarget(string ip) {
if (_pingAddresses.Contains(ip)) {
public void RemovePingTarget(string ip)
{
if (_pingAddresses.Contains(ip))
{
_pingAddresses.Remove(ip);
}
}
// 切换是否使用 Ping 检测
public void SetUsePingCheck(bool enablePing) {
public void SetUsePingCheck(bool enablePing)
{
usePingCheck = enablePing;
#if UNITY_WEBGL
usePingCheck = false;
@@ -273,8 +317,10 @@ usePingCheck = false;
_checkInterval = usePingCheck ? PingInterval : WebRequestInterval;
}
private bool QuickNetDeviceCheck() {
if (Application.isEditor) {
private bool QuickNetDeviceCheck()
{
if (Application.isEditor)
{
return true;
}
-1
View File
@@ -1,7 +1,6 @@
{
"dependencies": {
"com.unity.2d.sprite": "1.0.0",
"com.unity.addressables": "1.22.3",
"com.unity.collab-proxy": "2.7.1",
"com.unity.feature.development": "1.0.1",
"com.unity.nuget.newtonsoft-json": "3.2.1",
-21
View File
@@ -6,20 +6,6 @@
"source": "builtin",
"dependencies": {}
},
"com.unity.addressables": {
"version": "1.22.3",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.modules.assetbundle": "1.0.0",
"com.unity.modules.jsonserialize": "1.0.0",
"com.unity.modules.imageconversion": "1.0.0",
"com.unity.modules.unitywebrequest": "1.0.0",
"com.unity.scriptablebuildpipeline": "1.21.25",
"com.unity.modules.unitywebrequestassetbundle": "1.0.0"
},
"url": "https://packages.unity.com"
},
"com.unity.collab-proxy": {
"version": "2.7.1",
"depth": 0,
@@ -107,13 +93,6 @@
},
"url": "https://packages.unity.com"
},
"com.unity.scriptablebuildpipeline": {
"version": "1.21.25",
"depth": 1,
"source": "registry",
"dependencies": {},
"url": "https://packages.unity.com"
},
"com.unity.services.core": {
"version": "1.14.0",
"depth": 1,
+14
View File
@@ -1,5 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<projectSettings>
<projectSetting name="com.google.external-dependency-managerAnalyticsCookie" value="500b4bfa68f242ecbf2b37e490522e50" />
<projectSetting name="com.google.external-dependency-managerAnalyticsEnabled" value="True" />
<projectSetting name="Google.IOSResolver.AutoPodToolInstallInEditor" value="False" />
<projectSetting name="Google.IOSResolver.CocoapodsIntegrationMethod" value="2" />
<projectSetting name="Google.IOSResolver.PodfileAddUseFrameworks" value="True" />
<projectSetting name="Google.IOSResolver.PodfileAllowPodsInMultipleTargets" value="True" />
<projectSetting name="Google.IOSResolver.PodfileAlwaysAddMainTarget" value="True" />
<projectSetting name="Google.IOSResolver.PodfileEnabled" value="True" />
<projectSetting name="Google.IOSResolver.PodfileStaticLinkFrameworks" value="True" />
<projectSetting name="Google.IOSResolver.PodToolExecutionViaShellEnabled" value="True" />
<projectSetting name="Google.IOSResolver.PodToolShellExecutionSetLang" value="True" />
<projectSetting name="Google.IOSResolver.SwiftFrameworkSupportWorkaroundEnabled" value="True" />
<projectSetting name="Google.IOSResolver.SwiftLanguageVersion" value="5.0" />
<projectSetting name="Google.IOSResolver.VerboseLoggingEnabled" value="False" />
<projectSetting name="GooglePlayServices.PromptBeforeAutoResolution" value="False" />
<projectSetting name="GooglePlayServices.UseJetifier" value="True" />
</projectSettings>
+1 -1
View File
@@ -898,7 +898,7 @@ PlayerSettings:
WebGL: UNITY_VISUAL_SCRIPTING;ES3_TMPRO;ES3_UGUI
Windows Store Apps: UNITY_VISUAL_SCRIPTING;ES3_TMPRO;ES3_UGUI
XboxOne: UNITY_VISUAL_SCRIPTING;ES3_TMPRO;ES3_UGUI
iPhone: MAX;GAME_RELEASE1;UNITY_VISUAL_SCRIPTING;ES3_TMPRO;ES3_UGUI;USE_ADDRESSABLES;UNITY_IAP;UNITY_PURCHASING
iPhone: MAX;GAME_RELEASE1;UNITY_VISUAL_SCRIPTING;ES3_TMPRO;ES3_UGUI;UNITY_IAP;UNITY_PURCHASING
tvOS: UNITY_VISUAL_SCRIPTING;ES3_TMPRO;ES3_UGUI
additionalCompilerArguments: {}
platformArchitecture: {}