Add hot-update boot pipeline, UI bundles/atlas assets, and design docs.
Ignore AIClient/Library and AIClient/HybridCLRData permanently; include HybridCLR/YooAsset project setup and UI tooling. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
#if UNITY_EDITOR
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using YooAsset.Editor;
|
||||
|
||||
namespace AOT.Editor.YooAssetTools
|
||||
{
|
||||
/// <summary>
|
||||
/// 初始化 DefaultPackage 收集配置(Raw 热更 DLL)。
|
||||
/// </summary>
|
||||
public static class SetupBundleCollector
|
||||
{
|
||||
public const string PackageName = "DefaultPackage";
|
||||
public const string CollectPath = "Assets/Bundles/Raw";
|
||||
public const string DllBytesPath = "Assets/Bundles/Raw/HotUpdate.Runtime.bytes";
|
||||
|
||||
[MenuItem("AIGame/YooAsset/Setup Bundle Collector")]
|
||||
public static string Setup()
|
||||
{
|
||||
Directory.CreateDirectory(CollectPath);
|
||||
EnsurePlaceholderDllBytes();
|
||||
|
||||
var setting = BundleCollectorSettingData.Setting;
|
||||
setting.ShowPackageView = true;
|
||||
setting.UniqueBundleName = false;
|
||||
|
||||
var package = setting.Packages.FirstOrDefault(p => p.PackageName == PackageName);
|
||||
if (package == null)
|
||||
package = BundleCollectorSettingData.CreatePackage(PackageName);
|
||||
|
||||
package.PackageDesc = "启动必需:热更 DLL 等";
|
||||
package.EnableAddressable = true;
|
||||
package.SupportExtensionless = true;
|
||||
package.LocationToLower = false;
|
||||
package.IncludeAssetGUID = false;
|
||||
package.AutoCollectShaders = false;
|
||||
package.IgnoreRuleName = nameof(RawFileIgnoreRule);
|
||||
BundleCollectorSettingData.ModifyPackage(package);
|
||||
|
||||
var group = package.Groups.FirstOrDefault(g => g.GroupName == "HotUpdateDll");
|
||||
if (group == null)
|
||||
group = BundleCollectorSettingData.CreateGroup(package, "HotUpdateDll");
|
||||
group.GroupDesc = "HybridCLR 热更程序集";
|
||||
group.ActiveRuleName = nameof(EnableGroup);
|
||||
group.AssetTags = "aot";
|
||||
BundleCollectorSettingData.ModifyGroup(package, group);
|
||||
|
||||
var collector = group.Collectors.FirstOrDefault(c => c.CollectPath == CollectPath);
|
||||
if (collector == null)
|
||||
{
|
||||
collector = new BundleCollector
|
||||
{
|
||||
CollectPath = CollectPath,
|
||||
CollectorGUID = AssetDatabase.AssetPathToGUID(CollectPath),
|
||||
CollectorType = ECollectorType.MainAssetCollector,
|
||||
AddressRuleName = nameof(AddressByFileName),
|
||||
PackRuleName = nameof(PackRawFile),
|
||||
FilterRuleName = nameof(CollectAll),
|
||||
AssetTags = "aot",
|
||||
};
|
||||
BundleCollectorSettingData.CreateCollector(group, collector);
|
||||
}
|
||||
else
|
||||
{
|
||||
collector.CollectorGUID = AssetDatabase.AssetPathToGUID(CollectPath);
|
||||
collector.CollectorType = ECollectorType.MainAssetCollector;
|
||||
collector.AddressRuleName = nameof(AddressByFileName);
|
||||
collector.PackRuleName = nameof(PackRawFile);
|
||||
collector.FilterRuleName = nameof(CollectAll);
|
||||
collector.AssetTags = "aot";
|
||||
BundleCollectorSettingData.ModifyCollector(group, collector);
|
||||
}
|
||||
|
||||
package.CheckConfigError();
|
||||
BundleCollectorSettingData.SaveFile();
|
||||
return $"ok package={PackageName} collect={CollectPath} dll={DllBytesPath} setting={AssetDatabase.GetAssetPath(setting)}";
|
||||
}
|
||||
|
||||
public static void EnsurePlaceholderDllBytes()
|
||||
{
|
||||
if (File.Exists(DllBytesPath))
|
||||
return;
|
||||
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(DllBytesPath) ?? CollectPath);
|
||||
// 占位:真实内容由 BuildAndStageHotUpdate 覆盖
|
||||
File.WriteAllBytes(DllBytesPath, System.Text.Encoding.UTF8.GetBytes("PLACEHOLDER_HOTUPDATE_DLL"));
|
||||
AssetDatabase.ImportAsset(DllBytesPath, ImportAssetOptions.ForceUpdate);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user