Skip to content

Commit 4c73f52

Browse files
committed
updated to v3.0.2 (modified BuildinCatalog access method)
1 parent abbd923 commit 4c73f52

40 files changed

Lines changed: 540 additions & 191 deletions

Assets/OxGFrame/AssetLoader/Scripts/Runtime/Bundle/BundleConfig.cs

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,18 @@ public static class BundleConfig
1818
public class SemanticRule
1919
{
2020
[ReadOnly]
21-
public bool major = true;
21+
[SerializeField]
22+
private bool _major = true;
23+
public bool major => this._major;
24+
2225
[ReadOnly]
23-
public bool minor = true;
26+
[SerializeField]
27+
private bool _minor = true;
28+
public bool minor => this._minor;
29+
2430
[SerializeField]
2531
private bool _patch = false;
26-
public bool patch { get { return this._patch; } }
32+
public bool patch => this._patch;
2733
}
2834

2935
public enum PlayMode
@@ -291,7 +297,8 @@ public static async UniTask<AppConfig> GetAppConfigFromStreamingAssets()
291297
if (_builtinAppConfig == null)
292298
{
293299
string cfgJson = await Requester.RequestText(GetStreamingAssetsAppConfigPath(), null, null, null, false);
294-
if (!string.IsNullOrEmpty(cfgJson)) _builtinAppConfig = JsonConvert.DeserializeObject<AppConfig>(cfgJson);
300+
if (!string.IsNullOrEmpty(cfgJson))
301+
_builtinAppConfig = JsonConvert.DeserializeObject<AppConfig>(cfgJson);
295302
}
296303
return _builtinAppConfig;
297304
}
@@ -306,7 +313,8 @@ public static async UniTask<AppConfig> GetAppConfigFromHostServer()
306313
{
307314
var url = await GetHostServerAppConfigPath();
308315
string cfgJson = await Requester.RequestText(url, null, null, null, false);
309-
if (!string.IsNullOrEmpty(cfgJson)) _hostAppConfig = JsonConvert.DeserializeObject<AppConfig>(cfgJson);
316+
if (!string.IsNullOrEmpty(cfgJson))
317+
_hostAppConfig = JsonConvert.DeserializeObject<AppConfig>(cfgJson);
310318
}
311319
return _hostAppConfig;
312320
}
@@ -365,8 +373,10 @@ public static async UniTask<string> GetDlcHostServerUrl(string packageName, stri
365373
string dlcFolderName = PatchSetting.setting.dlcFolderName;
366374

367375
// 預設 DLC 組合路徑
368-
if (withoutPlatform) return $"{host}/{rootFolderName}/{productName}/{dlcFolderName}/{packageName}/{dlcVersion}";
369-
else return $"{host}/{rootFolderName}/{productName}/{platform}/{dlcFolderName}/{packageName}/{dlcVersion}";
376+
if (withoutPlatform)
377+
return $"{host}/{rootFolderName}/{productName}/{dlcFolderName}/{packageName}/{dlcVersion}";
378+
else
379+
return $"{host}/{rootFolderName}/{productName}/{platform}/{dlcFolderName}/{packageName}/{dlcVersion}";
370380
}
371381

372382
/// <summary>
@@ -383,8 +393,10 @@ public static async UniTask<string> GetDlcFallbackHostServerUrl(string packageNa
383393
string dlcFolderName = PatchSetting.setting.dlcFolderName;
384394

385395
// 預設 DLC 組合路徑
386-
if (withoutPlatform) return $"{host}/{rootFolderName}/{productName}/{dlcFolderName}/{packageName}/{dlcVersion}";
387-
else return $"{host}/{rootFolderName}/{productName}/{platform}/{dlcFolderName}/{packageName}/{dlcVersion}";
396+
if (withoutPlatform)
397+
return $"{host}/{rootFolderName}/{productName}/{dlcFolderName}/{packageName}/{dlcVersion}";
398+
else
399+
return $"{host}/{rootFolderName}/{productName}/{platform}/{dlcFolderName}/{packageName}/{dlcVersion}";
388400
}
389401

390402
/// <summary>

Assets/OxGFrame/AssetLoader/Scripts/Runtime/Bundle/YooAssets/StreamingAssetsHelper/StreamingAssetsHelper.cs

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -161,30 +161,7 @@ private static void _ExportBuiltinPackageCatalogFile()
161161
[UnityEditor.MenuItem("YooAsset/" + "OxGFrame Pre-Export Built-in Catalog File (BuildinCatalog) used by YooAsset", false, 1099)]
162162
private static void _ExportBuiltinCatalogFile()
163163
{
164-
string savePath = YooAssetBridge.YooAssetSettingsData.GetYooResourcesFullPath();
165-
if (UnityEditor.AssetDatabase.DeleteAsset(savePath))
166-
UnityEditor.AssetDatabase.Refresh();
167-
168-
string rootPath = YooAssetBridge.YooAssetSettingsData.GetYooDefaultBuildinRoot();
169-
DirectoryInfo rootDirectory = new DirectoryInfo(rootPath);
170-
if (rootDirectory.Exists == false)
171-
{
172-
UnityEngine.Debug.LogWarning($"Can not found StreamingAssets root directory : {rootPath}");
173-
return;
174-
}
175-
176-
// 搜索所有 Package 目录
177-
DirectoryInfo[] subDirectories = rootDirectory.GetDirectories();
178-
foreach (var subDirectory in subDirectories)
179-
{
180-
string packageName = subDirectory.Name;
181-
string pacakgeDirectory = subDirectory.FullName;
182-
bool result = DefaultBuildinFileSystemBuild.CreateBuildinCatalogFile(packageName, pacakgeDirectory);
183-
if (result == false)
184-
{
185-
throw new System.Exception($"Create package {packageName} catalog file failed ! See the detail error in console !");
186-
}
187-
}
164+
DefaultBuildinFileSystemBuild.ExportBuildinCatalogFile();
188165
}
189166

190167
private static BuiltinPackageCatalog _CollectBuiltinPackages(DirectoryInfo root)

Assets/OxGFrame/AssetLoader/ThirdParty/YooAsset/CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
All notable changes to this package will be documented in this file.
44

5+
## [2.3.5-preview] - 2025-03-14
6+
7+
### Fixed
8+
9+
- (#502) 修复了原生缓存文件由于文件格式变动导致的加载本地缓存文件失败的问题。
10+
- (#504) 修复了MacOS平台Offline Play Mode模式请求本地资源清单失败的问题。
11+
- (#506) 修复了v2.3x版本LoadAllAssets方法计算依赖Bundle不完整的问题。
12+
- (#506) 修复了微信小游戏文件系统,在启用加密算法后卸载bundle报错的问题。
13+
514
## [2.3.4-preview] - 2025-03-08
615

716
### Improvements
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System.Collections.Generic;
2+
3+
namespace YooAsset.Editor
4+
{
5+
public class MacroDefine
6+
{
7+
/// <summary>
8+
/// YooAsset版本宏定义
9+
/// </summary>
10+
public static readonly List<string> Macros = new List<string>()
11+
{
12+
"YOO_ASSET_2",
13+
"YOO_ASSET_2_3",
14+
"YOO_ASSET_2_3_OR_NEWER",
15+
};
16+
}
17+
}

Assets/OxGFrame/AssetLoader/ThirdParty/YooAsset/Editor/Assembly/MacroDefine.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/OxGFrame/AssetLoader/ThirdParty/YooAsset/Editor/Assembly/MacrosProcessor.cs renamed to Assets/OxGFrame/AssetLoader/ThirdParty/YooAsset/Editor/Assembly/MacroProcessor.cs

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,15 @@
11
using System.Collections.Generic;
22
using System.IO;
33
using System.Linq;
4+
using System.Text;
45
using System.Xml;
56
using UnityEditor;
67

78
namespace YooAsset.Editor
89
{
910
[InitializeOnLoad]
10-
public class MacrosProcessor : AssetPostprocessor
11+
public class MacroProcessor : AssetPostprocessor
1112
{
12-
static MacrosProcessor()
13-
{
14-
}
15-
16-
/// <summary>
17-
/// YooAsset版本宏定义
18-
/// </summary>
19-
private static readonly List<string> YooAssetMacros = new List<string>()
20-
{
21-
"YOO_ASSET_2",
22-
"YOO_ASSET_2_3",
23-
"YOO_ASSET_2_3_OR_NEWER",
24-
};
25-
2613
static string OnGeneratedCSProject(string path, string content)
2714
{
2815
XmlDocument xmlDoc = new XmlDocument();
@@ -65,7 +52,7 @@ private static bool ProcessDefineConstants(XmlElement element)
6552

6653
string[] defines = childNode.InnerText.Split(';');
6754
HashSet<string> hashSets = new HashSet<string>(defines);
68-
foreach (string yooMacro in YooAssetMacros)
55+
foreach (string yooMacro in MacroDefine.Macros)
6956
{
7057
string tmpMacro = yooMacro.Trim();
7158
if (hashSets.Contains(tmpMacro) == false)

Assets/OxGFrame/AssetLoader/ThirdParty/YooAsset/Editor/Assembly/MacrosProcessor.cs.meta renamed to Assets/OxGFrame/AssetLoader/ThirdParty/YooAsset/Editor/Assembly/MacroProcessor.cs.meta

File renamed without changes.
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
using System.Collections.Generic;
2+
using System.IO;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Xml;
6+
using UnityEditor;
7+
using UnityEngine;
8+
9+
#if YOO_ASSET_EXPERIMENT
10+
namespace YooAsset.Editor.Experiment
11+
{
12+
[InitializeOnLoad]
13+
public class RspGenerator
14+
{
15+
// csc.rsp文件路径
16+
private static string RspFilePath => Path.Combine(Application.dataPath, "csc.rsp");
17+
18+
static RspGenerator()
19+
{
20+
UpdateRspFile(MacroDefine.Macros, null);
21+
}
22+
23+
/// <summary>
24+
/// 更新csc.rsp文件
25+
/// </summary>
26+
private static void UpdateRspFile(List<string> addMacros, List<string> removeMacros)
27+
{
28+
var existingDefines = new HashSet<string>();
29+
var otherLines = new List<string>();
30+
31+
// 1. 读取现有内容
32+
ReadRspFile(existingDefines, otherLines);
33+
34+
// 2. 添加新宏
35+
if (addMacros != null && addMacros.Count > 0)
36+
{
37+
addMacros.ForEach(x =>
38+
{
39+
if (existingDefines.Contains(x) == false)
40+
existingDefines.Add(x);
41+
});
42+
}
43+
44+
// 3. 移除指定宏
45+
if (removeMacros != null && removeMacros.Count > 0)
46+
{
47+
removeMacros.ForEach(x =>
48+
{
49+
existingDefines.Remove(x);
50+
});
51+
}
52+
53+
// 4. 重新生成内容
54+
WriteRspFile(existingDefines, otherLines);
55+
56+
// 5. 刷新AssetDatabase
57+
AssetDatabase.Refresh();
58+
EditorUtility.RequestScriptReload();
59+
}
60+
61+
/// <summary>
62+
/// 读取csc.rsp文件,返回宏定义和其他行
63+
/// </summary>
64+
private static void ReadRspFile(HashSet<string> defines, List<string> others)
65+
{
66+
if (defines == null)
67+
defines = new HashSet<string>();
68+
69+
if (others == null)
70+
others = new List<string>();
71+
72+
if (File.Exists(RspFilePath) == false)
73+
return;
74+
75+
foreach (string line in File.ReadAllLines(RspFilePath))
76+
{
77+
if (line.StartsWith("-define:"))
78+
{
79+
string[] parts = line.Split(new[] { ':' }, 2);
80+
if (parts.Length == 2)
81+
{
82+
defines.Add(parts[1].Trim());
83+
}
84+
}
85+
else
86+
{
87+
others.Add(line);
88+
}
89+
}
90+
}
91+
92+
/// <summary>
93+
/// 重新写入csc.rsp文件
94+
/// </summary>
95+
private static void WriteRspFile(HashSet<string> defines, List<string> others)
96+
{
97+
StringBuilder sb = new StringBuilder();
98+
if (others != null && others.Count > 0)
99+
{
100+
others.ForEach(o => sb.AppendLine(o));
101+
}
102+
103+
if (defines != null && defines.Count > 0)
104+
{
105+
foreach (string define in defines)
106+
{
107+
sb.AppendLine($"-define:{define}");
108+
}
109+
}
110+
111+
File.WriteAllText(RspFilePath, sb.ToString());
112+
}
113+
}
114+
}
115+
#endif

Assets/OxGFrame/AssetLoader/ThirdParty/YooAsset/Editor/Assembly/RspGenerator.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/OxGFrame/AssetLoader/ThirdParty/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/BuiltinBuildPipeline/BuildTasks/TaskCopyBuildinFiles_BBP.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ void IBuildTask.Run(BuildContext context)
1515
if (buildParametersContext.Parameters.BuildinFileCopyOption != EBuildinFileCopyOption.None)
1616
{
1717
CopyBuildinFilesToStreaming(buildParametersContext, manifestContext.Manifest);
18+
DefaultBuildinFileSystemBuild.ExportBuildinCatalogFile();
1819
}
1920
}
2021
}

0 commit comments

Comments
 (0)