mirror of https://github.com/tuyoogame/YooAsset
Compare commits
3 Commits
1d5663d93a
...
f24ae6eb2a
Author | SHA1 | Date |
---|---|---|
|
f24ae6eb2a | |
|
3bb3d4382c | |
|
43db19c257 |
|
@ -30,6 +30,11 @@ namespace YooAsset.Editor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string AssetPath { private set; get; }
|
public string AssetPath { private set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资源GUID
|
||||||
|
/// </summary>
|
||||||
|
public string AssetGUID { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否为原生资源
|
/// 是否为原生资源
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -65,6 +70,7 @@ namespace YooAsset.Editor
|
||||||
AssetPath = assetPath;
|
AssetPath = assetPath;
|
||||||
IsRawAsset = isRawAsset;
|
IsRawAsset = isRawAsset;
|
||||||
|
|
||||||
|
AssetGUID = UnityEditor.AssetDatabase.AssetPathToGUID(assetPath);
|
||||||
System.Type assetType = UnityEditor.AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
System.Type assetType = UnityEditor.AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
||||||
if (assetType == typeof(UnityEngine.Shader) || assetType == typeof(UnityEngine.ShaderVariantCollection))
|
if (assetType == typeof(UnityEngine.Shader) || assetType == typeof(UnityEngine.ShaderVariantCollection))
|
||||||
IsShaderAsset = true;
|
IsShaderAsset = true;
|
||||||
|
@ -78,6 +84,7 @@ namespace YooAsset.Editor
|
||||||
AssetPath = assetPath;
|
AssetPath = assetPath;
|
||||||
IsRawAsset = false;
|
IsRawAsset = false;
|
||||||
|
|
||||||
|
AssetGUID = UnityEditor.AssetDatabase.AssetPathToGUID(assetPath);
|
||||||
System.Type assetType = UnityEditor.AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
System.Type assetType = UnityEditor.AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
||||||
if (assetType == typeof(UnityEngine.Shader) || assetType == typeof(UnityEngine.ShaderVariantCollection))
|
if (assetType == typeof(UnityEngine.Shader) || assetType == typeof(UnityEngine.ShaderVariantCollection))
|
||||||
IsShaderAsset = true;
|
IsShaderAsset = true;
|
||||||
|
|
|
@ -22,19 +22,9 @@ namespace YooAsset.Editor
|
||||||
public int AssetFileCount;
|
public int AssetFileCount;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否启用可寻址资源定位
|
/// 收集命令
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool EnableAddressable;
|
public CollectCommand Command { set; get; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 资源包名唯一化
|
|
||||||
/// </summary>
|
|
||||||
public bool UniqueBundleName;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 着色器统一的全名称
|
|
||||||
/// </summary>
|
|
||||||
public string ShadersBundleName;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源包信息列表
|
/// 资源包信息列表
|
||||||
|
|
|
@ -58,6 +58,16 @@ namespace YooAsset.Editor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool EnableAddressable;
|
public bool EnableAddressable;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资源定位地址大小写不敏感
|
||||||
|
/// </summary>
|
||||||
|
public bool LocationToLower;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 包含资源GUID数据
|
||||||
|
/// </summary>
|
||||||
|
public bool IncludeAssetGUID;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源包名唯一化
|
/// 资源包名唯一化
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -33,7 +33,7 @@ namespace YooAsset.Editor
|
||||||
// 开始构建
|
// 开始构建
|
||||||
IBundleBuildResults buildResults;
|
IBundleBuildResults buildResults;
|
||||||
var buildParameters = buildParametersContext.GetSBPBuildParameters();
|
var buildParameters = buildParametersContext.GetSBPBuildParameters();
|
||||||
var taskList = SBPBuildTasks.Create(buildMapContext.ShadersBundleName);
|
var taskList = SBPBuildTasks.Create(buildMapContext.Command.ShadersBundleName);
|
||||||
ReturnCode exitCode = ContentPipeline.BuildAssetBundles(buildParameters, buildContent, out buildResults, taskList);
|
ReturnCode exitCode = ContentPipeline.BuildAssetBundles(buildParameters, buildContent, out buildResults, taskList);
|
||||||
if (exitCode < 0)
|
if (exitCode < 0)
|
||||||
{
|
{
|
||||||
|
@ -43,7 +43,7 @@ namespace YooAsset.Editor
|
||||||
// 创建着色器信息
|
// 创建着色器信息
|
||||||
// 说明:解决因为着色器资源包导致验证失败。
|
// 说明:解决因为着色器资源包导致验证失败。
|
||||||
// 例如:当项目里没有着色器,如果有依赖内置着色器就会验证失败。
|
// 例如:当项目里没有着色器,如果有依赖内置着色器就会验证失败。
|
||||||
string shadersBundleName = buildMapContext.ShadersBundleName;
|
string shadersBundleName = buildMapContext.Command.ShadersBundleName;
|
||||||
if (buildResults.BundleInfos.ContainsKey(shadersBundleName))
|
if (buildResults.BundleInfos.ContainsKey(shadersBundleName))
|
||||||
{
|
{
|
||||||
buildMapContext.CreateShadersBundleInfo(shadersBundleName);
|
buildMapContext.CreateShadersBundleInfo(shadersBundleName);
|
||||||
|
|
|
@ -34,7 +34,9 @@ namespace YooAsset.Editor
|
||||||
// 创建新补丁清单
|
// 创建新补丁清单
|
||||||
PackageManifest manifest = new PackageManifest();
|
PackageManifest manifest = new PackageManifest();
|
||||||
manifest.FileVersion = YooAssetSettings.ManifestFileVersion;
|
manifest.FileVersion = YooAssetSettings.ManifestFileVersion;
|
||||||
manifest.EnableAddressable = buildMapContext.EnableAddressable;
|
manifest.EnableAddressable = buildMapContext.Command.EnableAddressable;
|
||||||
|
manifest.LocationToLower = buildMapContext.Command.LocationToLower;
|
||||||
|
manifest.IncludeAssetGUID = buildMapContext.Command.IncludeAssetGUID;
|
||||||
manifest.OutputNameStyle = (int)buildParameters.OutputNameStyle;
|
manifest.OutputNameStyle = (int)buildParameters.OutputNameStyle;
|
||||||
manifest.PackageName = buildParameters.PackageName;
|
manifest.PackageName = buildParameters.PackageName;
|
||||||
manifest.PackageVersion = buildParameters.PackageVersion;
|
manifest.PackageVersion = buildParameters.PackageVersion;
|
||||||
|
@ -47,7 +49,7 @@ namespace YooAsset.Editor
|
||||||
if (buildParameters.BuildMode == EBuildMode.IncrementalBuild)
|
if (buildParameters.BuildMode == EBuildMode.IncrementalBuild)
|
||||||
{
|
{
|
||||||
var buildResultContext = context.GetContextObject<TaskBuilding_SBP.BuildResultContext>();
|
var buildResultContext = context.GetContextObject<TaskBuilding_SBP.BuildResultContext>();
|
||||||
UpdateBuiltInBundleReference(manifest, buildResultContext, buildMapContext.ShadersBundleName);
|
UpdateBuiltInBundleReference(manifest, buildResultContext, buildMapContext.Command.ShadersBundleName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,11 +143,9 @@ namespace YooAsset.Editor
|
||||||
foreach (var assetInfo in assetInfos)
|
foreach (var assetInfo in assetInfos)
|
||||||
{
|
{
|
||||||
PackageAsset packageAsset = new PackageAsset();
|
PackageAsset packageAsset = new PackageAsset();
|
||||||
if (buildMapContext.EnableAddressable)
|
packageAsset.Address = buildMapContext.Command.EnableAddressable ? assetInfo.Address : string.Empty;
|
||||||
packageAsset.Address = assetInfo.Address;
|
|
||||||
else
|
|
||||||
packageAsset.Address = string.Empty;
|
|
||||||
packageAsset.AssetPath = assetInfo.AssetPath;
|
packageAsset.AssetPath = assetInfo.AssetPath;
|
||||||
|
packageAsset.AssetGUID = buildMapContext.Command.IncludeAssetGUID ? assetInfo.AssetGUID : string.Empty;
|
||||||
packageAsset.AssetTags = assetInfo.AssetTags.ToArray();
|
packageAsset.AssetTags = assetInfo.AssetTags.ToArray();
|
||||||
packageAsset.BundleID = GetAssetBundleID(assetInfo.BundleName, manifest);
|
packageAsset.BundleID = GetAssetBundleID(assetInfo.BundleName, manifest);
|
||||||
packageAsset.DependIDs = GetAssetBundleDependIDs(packageAsset.BundleID, assetInfo, manifest);
|
packageAsset.DependIDs = GetAssetBundleDependIDs(packageAsset.BundleID, assetInfo, manifest);
|
||||||
|
|
|
@ -45,8 +45,10 @@ namespace YooAsset.Editor
|
||||||
buildReport.Summary.BuildMode = buildParameters.BuildMode;
|
buildReport.Summary.BuildMode = buildParameters.BuildMode;
|
||||||
buildReport.Summary.BuildPackageName = buildParameters.PackageName;
|
buildReport.Summary.BuildPackageName = buildParameters.PackageName;
|
||||||
buildReport.Summary.BuildPackageVersion = buildParameters.PackageVersion;
|
buildReport.Summary.BuildPackageVersion = buildParameters.PackageVersion;
|
||||||
buildReport.Summary.EnableAddressable = buildMapContext.EnableAddressable;
|
buildReport.Summary.EnableAddressable = buildMapContext.Command.EnableAddressable;
|
||||||
buildReport.Summary.UniqueBundleName = buildMapContext.UniqueBundleName;
|
buildReport.Summary.LocationToLower = buildMapContext.Command.LocationToLower;
|
||||||
|
buildReport.Summary.IncludeAssetGUID = buildMapContext.Command.IncludeAssetGUID;
|
||||||
|
buildReport.Summary.UniqueBundleName = buildMapContext.Command.UniqueBundleName;
|
||||||
buildReport.Summary.AutoAnalyzeRedundancy = buildParameters.AutoAnalyzeRedundancy;
|
buildReport.Summary.AutoAnalyzeRedundancy = buildParameters.AutoAnalyzeRedundancy;
|
||||||
buildReport.Summary.ShareAssetPackRuleClassName = buildParameters.ShareAssetPackRule == null ?
|
buildReport.Summary.ShareAssetPackRuleClassName = buildParameters.ShareAssetPackRule == null ?
|
||||||
"null" : buildParameters.ShareAssetPackRule.GetType().FullName;
|
"null" : buildParameters.ShareAssetPackRule.GetType().FullName;
|
||||||
|
|
|
@ -98,9 +98,7 @@ namespace YooAsset.Editor
|
||||||
// 7. 记录关键信息
|
// 7. 记录关键信息
|
||||||
BuildMapContext context = new BuildMapContext();
|
BuildMapContext context = new BuildMapContext();
|
||||||
context.AssetFileCount = allBuildAssetInfoDic.Count;
|
context.AssetFileCount = allBuildAssetInfoDic.Count;
|
||||||
context.EnableAddressable = collectResult.Command.EnableAddressable;
|
context.Command = collectResult.Command;
|
||||||
context.UniqueBundleName = collectResult.Command.UniqueBundleName;
|
|
||||||
context.ShadersBundleName = collectResult.Command.ShadersBundleName;
|
|
||||||
|
|
||||||
// 8. 计算共享的资源包名
|
// 8. 计算共享的资源包名
|
||||||
if (autoAnalyzeRedundancy)
|
if (autoAnalyzeRedundancy)
|
||||||
|
|
|
@ -15,6 +15,8 @@ namespace YooAsset.Editor
|
||||||
public const string XmlVersion = "Version";
|
public const string XmlVersion = "Version";
|
||||||
public const string XmlCommon = "Common";
|
public const string XmlCommon = "Common";
|
||||||
public const string XmlEnableAddressable = "AutoAddressable";
|
public const string XmlEnableAddressable = "AutoAddressable";
|
||||||
|
public const string XmlLocationToLower = "LocationToLower";
|
||||||
|
public const string XmlIncludeAssetGUID = "IncludeAssetGUID";
|
||||||
public const string XmlUniqueBundleName = "UniqueBundleName";
|
public const string XmlUniqueBundleName = "UniqueBundleName";
|
||||||
public const string XmlShowPackageView = "ShowPackageView";
|
public const string XmlShowPackageView = "ShowPackageView";
|
||||||
public const string XmlShowEditorAlias = "ShowEditorAlias";
|
public const string XmlShowEditorAlias = "ShowEditorAlias";
|
||||||
|
@ -66,6 +68,8 @@ namespace YooAsset.Editor
|
||||||
|
|
||||||
// 读取公共配置
|
// 读取公共配置
|
||||||
bool enableAddressable = false;
|
bool enableAddressable = false;
|
||||||
|
bool locationToLower = false;
|
||||||
|
bool includeAssetGUID = false;
|
||||||
bool uniqueBundleName = false;
|
bool uniqueBundleName = false;
|
||||||
bool showPackageView = false;
|
bool showPackageView = false;
|
||||||
bool showEditorAlias = false;
|
bool showEditorAlias = false;
|
||||||
|
@ -73,18 +77,17 @@ namespace YooAsset.Editor
|
||||||
if (commonNodeList.Count > 0)
|
if (commonNodeList.Count > 0)
|
||||||
{
|
{
|
||||||
XmlElement commonElement = commonNodeList[0] as XmlElement;
|
XmlElement commonElement = commonNodeList[0] as XmlElement;
|
||||||
if (commonElement.HasAttribute(XmlEnableAddressable) == false)
|
if (commonElement.HasAttribute(XmlEnableAddressable))
|
||||||
throw new Exception($"Not found attribute {XmlEnableAddressable} in {XmlCommon}");
|
|
||||||
if (commonElement.HasAttribute(XmlUniqueBundleName) == false)
|
|
||||||
throw new Exception($"Not found attribute {XmlUniqueBundleName} in {XmlCommon}");
|
|
||||||
if (commonElement.HasAttribute(XmlShowPackageView) == false)
|
|
||||||
throw new Exception($"Not found attribute {XmlShowPackageView} in {XmlCommon}");
|
|
||||||
if (commonElement.HasAttribute(XmlShowEditorAlias) == false)
|
|
||||||
throw new Exception($"Not found attribute {XmlShowEditorAlias} in {XmlCommon}");
|
|
||||||
|
|
||||||
enableAddressable = commonElement.GetAttribute(XmlEnableAddressable) == "True" ? true : false;
|
enableAddressable = commonElement.GetAttribute(XmlEnableAddressable) == "True" ? true : false;
|
||||||
|
if (commonElement.HasAttribute(XmlLocationToLower))
|
||||||
|
locationToLower = commonElement.GetAttribute(XmlLocationToLower) == "True" ? true : false;
|
||||||
|
if (commonElement.HasAttribute(XmlIncludeAssetGUID))
|
||||||
|
includeAssetGUID = commonElement.GetAttribute(XmlIncludeAssetGUID) == "True" ? true : false;
|
||||||
|
if (commonElement.HasAttribute(XmlUniqueBundleName))
|
||||||
uniqueBundleName = commonElement.GetAttribute(XmlUniqueBundleName) == "True" ? true : false;
|
uniqueBundleName = commonElement.GetAttribute(XmlUniqueBundleName) == "True" ? true : false;
|
||||||
|
if (commonElement.HasAttribute(XmlShowPackageView))
|
||||||
showPackageView = commonElement.GetAttribute(XmlShowPackageView) == "True" ? true : false;
|
showPackageView = commonElement.GetAttribute(XmlShowPackageView) == "True" ? true : false;
|
||||||
|
if (commonElement.HasAttribute(XmlShowEditorAlias))
|
||||||
showEditorAlias = commonElement.GetAttribute(XmlShowEditorAlias) == "True" ? true : false;
|
showEditorAlias = commonElement.GetAttribute(XmlShowEditorAlias) == "True" ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,6 +173,8 @@ namespace YooAsset.Editor
|
||||||
// 保存配置数据
|
// 保存配置数据
|
||||||
AssetBundleCollectorSettingData.ClearAll();
|
AssetBundleCollectorSettingData.ClearAll();
|
||||||
AssetBundleCollectorSettingData.Setting.EnableAddressable = enableAddressable;
|
AssetBundleCollectorSettingData.Setting.EnableAddressable = enableAddressable;
|
||||||
|
AssetBundleCollectorSettingData.Setting.LocationToLower = locationToLower;
|
||||||
|
AssetBundleCollectorSettingData.Setting.IncludeAssetGUID = includeAssetGUID;
|
||||||
AssetBundleCollectorSettingData.Setting.UniqueBundleName = uniqueBundleName;
|
AssetBundleCollectorSettingData.Setting.UniqueBundleName = uniqueBundleName;
|
||||||
AssetBundleCollectorSettingData.Setting.ShowPackageView = showPackageView;
|
AssetBundleCollectorSettingData.Setting.ShowPackageView = showPackageView;
|
||||||
AssetBundleCollectorSettingData.Setting.ShowEditorAlias = showEditorAlias;
|
AssetBundleCollectorSettingData.Setting.ShowEditorAlias = showEditorAlias;
|
||||||
|
@ -201,6 +206,8 @@ namespace YooAsset.Editor
|
||||||
// 设置公共配置
|
// 设置公共配置
|
||||||
var commonElement = xmlDoc.CreateElement(XmlCommon);
|
var commonElement = xmlDoc.CreateElement(XmlCommon);
|
||||||
commonElement.SetAttribute(XmlEnableAddressable, AssetBundleCollectorSettingData.Setting.EnableAddressable.ToString());
|
commonElement.SetAttribute(XmlEnableAddressable, AssetBundleCollectorSettingData.Setting.EnableAddressable.ToString());
|
||||||
|
commonElement.SetAttribute(XmlLocationToLower, AssetBundleCollectorSettingData.Setting.LocationToLower.ToString());
|
||||||
|
commonElement.SetAttribute(XmlIncludeAssetGUID, AssetBundleCollectorSettingData.Setting.IncludeAssetGUID.ToString());
|
||||||
commonElement.SetAttribute(XmlUniqueBundleName, AssetBundleCollectorSettingData.Setting.UniqueBundleName.ToString());
|
commonElement.SetAttribute(XmlUniqueBundleName, AssetBundleCollectorSettingData.Setting.UniqueBundleName.ToString());
|
||||||
commonElement.SetAttribute(XmlShowPackageView, AssetBundleCollectorSettingData.Setting.ShowPackageView.ToString());
|
commonElement.SetAttribute(XmlShowPackageView, AssetBundleCollectorSettingData.Setting.ShowPackageView.ToString());
|
||||||
commonElement.SetAttribute(XmlShowEditorAlias, AssetBundleCollectorSettingData.Setting.ShowEditorAlias.ToString());
|
commonElement.SetAttribute(XmlShowEditorAlias, AssetBundleCollectorSettingData.Setting.ShowEditorAlias.ToString());
|
||||||
|
|
|
@ -10,15 +10,25 @@ namespace YooAsset.Editor
|
||||||
public class AssetBundleCollectorSetting : ScriptableObject
|
public class AssetBundleCollectorSetting : ScriptableObject
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否显示包裹列表视图
|
/// 显示包裹列表视图
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool ShowPackageView = false;
|
public bool ShowPackageView = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否启用可寻址资源定位
|
/// 启用可寻址资源定位
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool EnableAddressable = false;
|
public bool EnableAddressable = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资源定位地址大小写不敏感
|
||||||
|
/// </summary>
|
||||||
|
public bool LocationToLower = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 包含资源GUID数据
|
||||||
|
/// </summary>
|
||||||
|
public bool IncludeAssetGUID = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源包名唯一化
|
/// 资源包名唯一化
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -41,7 +51,12 @@ namespace YooAsset.Editor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void ClearAll()
|
public void ClearAll()
|
||||||
{
|
{
|
||||||
|
ShowPackageView = false;
|
||||||
EnableAddressable = false;
|
EnableAddressable = false;
|
||||||
|
LocationToLower = false;
|
||||||
|
IncludeAssetGUID = false;
|
||||||
|
UniqueBundleName = false;
|
||||||
|
ShowEditorAlias = false;
|
||||||
Packages.Clear();
|
Packages.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,7 +116,8 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
if (package.PackageName == packageName)
|
if (package.PackageName == packageName)
|
||||||
{
|
{
|
||||||
CollectCommand command = new CollectCommand(buildMode, packageName, EnableAddressable, UniqueBundleName);
|
CollectCommand command = new CollectCommand(buildMode, packageName,
|
||||||
|
EnableAddressable, LocationToLower, IncludeAssetGUID, UniqueBundleName);
|
||||||
CollectResult collectResult = new CollectResult(command);
|
CollectResult collectResult = new CollectResult(command);
|
||||||
collectResult.SetCollectAssets(package.GetAllCollectAssets(command));
|
collectResult.SetCollectAssets(package.GetAllCollectAssets(command));
|
||||||
return collectResult;
|
return collectResult;
|
||||||
|
|
|
@ -331,6 +331,16 @@ namespace YooAsset.Editor
|
||||||
Setting.EnableAddressable = enableAddressable;
|
Setting.EnableAddressable = enableAddressable;
|
||||||
IsDirty = true;
|
IsDirty = true;
|
||||||
}
|
}
|
||||||
|
public static void ModifyLocationToLower(bool locationToLower)
|
||||||
|
{
|
||||||
|
Setting.LocationToLower = locationToLower;
|
||||||
|
IsDirty = true;
|
||||||
|
}
|
||||||
|
public static void ModifyIncludeAssetGUID(bool includeAssetGUID)
|
||||||
|
{
|
||||||
|
Setting.IncludeAssetGUID = includeAssetGUID;
|
||||||
|
IsDirty = true;
|
||||||
|
}
|
||||||
public static void ModifyUniqueBundleName(bool uniqueBundleName)
|
public static void ModifyUniqueBundleName(bool uniqueBundleName)
|
||||||
{
|
{
|
||||||
Setting.UniqueBundleName = uniqueBundleName;
|
Setting.UniqueBundleName = uniqueBundleName;
|
||||||
|
|
|
@ -25,8 +25,13 @@ namespace YooAsset.Editor
|
||||||
private List<RuleDisplayName> _packRuleList;
|
private List<RuleDisplayName> _packRuleList;
|
||||||
private List<RuleDisplayName> _filterRuleList;
|
private List<RuleDisplayName> _filterRuleList;
|
||||||
|
|
||||||
|
private Button _settingsButton;
|
||||||
|
private VisualElement _setting1Container;
|
||||||
|
private VisualElement _setting2Container;
|
||||||
private Toggle _showPackageToogle;
|
private Toggle _showPackageToogle;
|
||||||
private Toggle _enableAddressableToogle;
|
private Toggle _enableAddressableToogle;
|
||||||
|
private Toggle _locationToLowerToogle;
|
||||||
|
private Toggle _includeAssetGUIDToogle;
|
||||||
private Toggle _uniqueBundleNameToogle;
|
private Toggle _uniqueBundleNameToogle;
|
||||||
private Toggle _showEditorAliasToggle;
|
private Toggle _showEditorAliasToggle;
|
||||||
|
|
||||||
|
@ -47,6 +52,7 @@ namespace YooAsset.Editor
|
||||||
|
|
||||||
private int _lastModifyPackageIndex = 0;
|
private int _lastModifyPackageIndex = 0;
|
||||||
private int _lastModifyGroupIndex = 0;
|
private int _lastModifyGroupIndex = 0;
|
||||||
|
private bool _showSettings = false;
|
||||||
|
|
||||||
|
|
||||||
public void CreateGUI()
|
public void CreateGUI()
|
||||||
|
@ -77,6 +83,10 @@ namespace YooAsset.Editor
|
||||||
visualAsset.CloneTree(root);
|
visualAsset.CloneTree(root);
|
||||||
|
|
||||||
// 公共设置相关
|
// 公共设置相关
|
||||||
|
_settingsButton = root.Q<Button>("SettingsButton");
|
||||||
|
_settingsButton.clicked += SettingsBtn_clicked;
|
||||||
|
_setting1Container = root.Q("PublicContainer1");
|
||||||
|
_setting2Container = root.Q("PublicContainer2");
|
||||||
_showPackageToogle = root.Q<Toggle>("ShowPackages");
|
_showPackageToogle = root.Q<Toggle>("ShowPackages");
|
||||||
_showPackageToogle.RegisterValueChangedCallback(evt =>
|
_showPackageToogle.RegisterValueChangedCallback(evt =>
|
||||||
{
|
{
|
||||||
|
@ -89,13 +99,24 @@ namespace YooAsset.Editor
|
||||||
AssetBundleCollectorSettingData.ModifyAddressable(evt.newValue);
|
AssetBundleCollectorSettingData.ModifyAddressable(evt.newValue);
|
||||||
RefreshWindow();
|
RefreshWindow();
|
||||||
});
|
});
|
||||||
|
_locationToLowerToogle = root.Q<Toggle>("LocationToLower");
|
||||||
|
_locationToLowerToogle.RegisterValueChangedCallback(evt =>
|
||||||
|
{
|
||||||
|
AssetBundleCollectorSettingData.ModifyLocationToLower(evt.newValue);
|
||||||
|
RefreshWindow();
|
||||||
|
});
|
||||||
|
_includeAssetGUIDToogle = root.Q<Toggle>("IncludeAssetGUID");
|
||||||
|
_includeAssetGUIDToogle.RegisterValueChangedCallback(evt =>
|
||||||
|
{
|
||||||
|
AssetBundleCollectorSettingData.ModifyIncludeAssetGUID(evt.newValue);
|
||||||
|
RefreshWindow();
|
||||||
|
});
|
||||||
_uniqueBundleNameToogle = root.Q<Toggle>("UniqueBundleName");
|
_uniqueBundleNameToogle = root.Q<Toggle>("UniqueBundleName");
|
||||||
_uniqueBundleNameToogle.RegisterValueChangedCallback(evt =>
|
_uniqueBundleNameToogle.RegisterValueChangedCallback(evt =>
|
||||||
{
|
{
|
||||||
AssetBundleCollectorSettingData.ModifyUniqueBundleName(evt.newValue);
|
AssetBundleCollectorSettingData.ModifyUniqueBundleName(evt.newValue);
|
||||||
RefreshWindow();
|
RefreshWindow();
|
||||||
});
|
});
|
||||||
|
|
||||||
_showEditorAliasToggle = root.Q<Toggle>("ShowEditorAlias");
|
_showEditorAliasToggle = root.Q<Toggle>("ShowEditorAlias");
|
||||||
_showEditorAliasToggle.RegisterValueChangedCallback(evt =>
|
_showEditorAliasToggle.RegisterValueChangedCallback(evt =>
|
||||||
{
|
{
|
||||||
|
@ -302,9 +323,22 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
_showPackageToogle.SetValueWithoutNotify(AssetBundleCollectorSettingData.Setting.ShowPackageView);
|
_showPackageToogle.SetValueWithoutNotify(AssetBundleCollectorSettingData.Setting.ShowPackageView);
|
||||||
_enableAddressableToogle.SetValueWithoutNotify(AssetBundleCollectorSettingData.Setting.EnableAddressable);
|
_enableAddressableToogle.SetValueWithoutNotify(AssetBundleCollectorSettingData.Setting.EnableAddressable);
|
||||||
|
_locationToLowerToogle.SetValueWithoutNotify(AssetBundleCollectorSettingData.Setting.LocationToLower);
|
||||||
|
_includeAssetGUIDToogle.SetValueWithoutNotify(AssetBundleCollectorSettingData.Setting.IncludeAssetGUID);
|
||||||
_uniqueBundleNameToogle.SetValueWithoutNotify(AssetBundleCollectorSettingData.Setting.UniqueBundleName);
|
_uniqueBundleNameToogle.SetValueWithoutNotify(AssetBundleCollectorSettingData.Setting.UniqueBundleName);
|
||||||
_showEditorAliasToggle.SetValueWithoutNotify(AssetBundleCollectorSettingData.Setting.ShowEditorAlias);
|
_showEditorAliasToggle.SetValueWithoutNotify(AssetBundleCollectorSettingData.Setting.ShowEditorAlias);
|
||||||
|
|
||||||
|
if (_showSettings)
|
||||||
|
{
|
||||||
|
_setting1Container.style.display = DisplayStyle.Flex;
|
||||||
|
_setting2Container.style.display = DisplayStyle.Flex;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_setting1Container.style.display = DisplayStyle.None;
|
||||||
|
_setting2Container.style.display = DisplayStyle.None;
|
||||||
|
}
|
||||||
|
|
||||||
_groupContainer.visible = false;
|
_groupContainer.visible = false;
|
||||||
_collectorContainer.visible = false;
|
_collectorContainer.visible = false;
|
||||||
|
|
||||||
|
@ -336,6 +370,11 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
AssetBundleCollectorSettingData.SaveFile();
|
AssetBundleCollectorSettingData.SaveFile();
|
||||||
}
|
}
|
||||||
|
private void SettingsBtn_clicked()
|
||||||
|
{
|
||||||
|
_showSettings = !_showSettings;
|
||||||
|
RefreshWindow();
|
||||||
|
}
|
||||||
private string FormatListItemCallback(RuleDisplayName ruleDisplayName)
|
private string FormatListItemCallback(RuleDisplayName ruleDisplayName)
|
||||||
{
|
{
|
||||||
if (_showEditorAliasToggle.value)
|
if (_showEditorAliasToggle.value)
|
||||||
|
@ -796,7 +835,8 @@ namespace YooAsset.Editor
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
CollectCommand command = new CollectCommand(EBuildMode.SimulateBuild, _packageNameTxt.value, _enableAddressableToogle.value, _uniqueBundleNameToogle.value);
|
CollectCommand command = new CollectCommand(EBuildMode.SimulateBuild, _packageNameTxt.value,
|
||||||
|
_enableAddressableToogle.value, _locationToLowerToogle.value, _includeAssetGUIDToogle.value, _uniqueBundleNameToogle.value);
|
||||||
collectAssetInfos = collector.GetAllCollectAssets(command, group);
|
collectAssetInfos = collector.GetAllCollectAssets(command, group);
|
||||||
}
|
}
|
||||||
catch (System.Exception e)
|
catch (System.Exception e)
|
||||||
|
|
|
@ -1,16 +1,23 @@
|
||||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements">
|
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
|
||||||
<uie:Toolbar name="Toolbar" style="display: flex; flex-direction: row-reverse;">
|
<uie:Toolbar name="Toolbar" style="display: flex; flex-direction: row-reverse;">
|
||||||
<ui:Button text="Save" display-tooltip-when-elided="true" name="SaveButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
|
<ui:Button text="Save" display-tooltip-when-elided="true" name="SaveButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
|
||||||
<ui:Button text="导出" display-tooltip-when-elided="true" name="ExportButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
|
<ui:Button text="导出" display-tooltip-when-elided="true" name="ExportButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
|
||||||
<ui:Button text="导入" display-tooltip-when-elided="true" name="ImportButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
|
<ui:Button text="导入" display-tooltip-when-elided="true" name="ImportButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
|
||||||
<ui:Button text="修复" display-tooltip-when-elided="true" name="FixButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
|
<ui:Button text="修复" display-tooltip-when-elided="true" name="FixButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
|
||||||
</uie:Toolbar>
|
</uie:Toolbar>
|
||||||
<ui:VisualElement name="PublicContainer" style="height: 30px; background-color: rgb(67, 67, 67); flex-direction: row; border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px;">
|
<ui:VisualElement name="PublicContainer" style="background-color: rgb(79, 79, 79); flex-direction: column; border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px;">
|
||||||
|
<ui:Button text="Settings" display-tooltip-when-elided="true" name="SettingsButton" />
|
||||||
|
<ui:VisualElement name="PublicContainer1" style="flex-direction: row; flex-wrap: nowrap; height: 28px;">
|
||||||
<ui:Toggle label="Show Packages" name="ShowPackages" style="width: 196px; -unity-text-align: middle-left;" />
|
<ui:Toggle label="Show Packages" name="ShowPackages" style="width: 196px; -unity-text-align: middle-left;" />
|
||||||
<ui:Toggle label="Show Editor Alias" name="ShowEditorAlias" style="width: 196px; -unity-text-align: middle-left;" />
|
<ui:Toggle label="Show Editor Alias" name="ShowEditorAlias" style="width: 196px; -unity-text-align: middle-left;" />
|
||||||
<ui:Toggle label="Enable Addressable" name="EnableAddressable" style="width: 196px; -unity-text-align: middle-left;" />
|
<ui:Toggle label="Enable Addressable" name="EnableAddressable" style="width: 196px; -unity-text-align: middle-left;" />
|
||||||
<ui:Toggle label="Unique Bundle Name" name="UniqueBundleName" style="width: 196px; -unity-text-align: middle-left;" />
|
<ui:Toggle label="Unique Bundle Name" name="UniqueBundleName" style="width: 196px; -unity-text-align: middle-left;" />
|
||||||
</ui:VisualElement>
|
</ui:VisualElement>
|
||||||
|
<ui:VisualElement name="PublicContainer2" style="flex-direction: row; flex-wrap: nowrap; height: 28px;">
|
||||||
|
<ui:Toggle label="Location To Lower" name="LocationToLower" style="width: 196px; -unity-text-align: middle-left;" />
|
||||||
|
<ui:Toggle label="Include Asset GUID" name="IncludeAssetGUID" style="width: 196px; -unity-text-align: middle-left;" />
|
||||||
|
</ui:VisualElement>
|
||||||
|
</ui:VisualElement>
|
||||||
<ui:VisualElement name="ContentContainer" style="flex-grow: 1; flex-direction: row;">
|
<ui:VisualElement name="ContentContainer" style="flex-grow: 1; flex-direction: row;">
|
||||||
<ui:VisualElement name="PackageContainer" style="width: 200px; flex-grow: 0; background-color: rgb(67, 67, 67); border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px;">
|
<ui:VisualElement name="PackageContainer" style="width: 200px; flex-grow: 0; background-color: rgb(67, 67, 67); border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px;">
|
||||||
<ui:Label text="Packages" display-tooltip-when-elided="true" name="PackageTitle" style="background-color: rgb(89, 89, 89); -unity-text-align: upper-center; -unity-font-style: bold; border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px; font-size: 12px;" />
|
<ui:Label text="Packages" display-tooltip-when-elided="true" name="PackageTitle" style="background-color: rgb(89, 89, 89); -unity-text-align: upper-center; -unity-font-style: bold; border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px; font-size: 12px;" />
|
||||||
|
|
|
@ -14,10 +14,20 @@ namespace YooAsset.Editor
|
||||||
public string PackageName { private set; get; }
|
public string PackageName { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否启用可寻址资源定位
|
/// 启用可寻址资源定位
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool EnableAddressable { private set; get; }
|
public bool EnableAddressable { private set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资源定位地址大小写不敏感
|
||||||
|
/// </summary>
|
||||||
|
public bool LocationToLower { private set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 包含资源GUID数据
|
||||||
|
/// </summary>
|
||||||
|
public bool IncludeAssetGUID { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源包名唯一化
|
/// 资源包名唯一化
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -29,11 +39,13 @@ namespace YooAsset.Editor
|
||||||
public string ShadersBundleName { private set; get; }
|
public string ShadersBundleName { private set; get; }
|
||||||
|
|
||||||
|
|
||||||
public CollectCommand(EBuildMode buildMode, string packageName, bool enableAddressable, bool uniqueBundleName)
|
public CollectCommand(EBuildMode buildMode, string packageName, bool enableAddressable, bool locationToLower, bool includeAssetGUID, bool uniqueBundleName)
|
||||||
{
|
{
|
||||||
BuildMode = buildMode;
|
BuildMode = buildMode;
|
||||||
PackageName = packageName;
|
PackageName = packageName;
|
||||||
EnableAddressable = enableAddressable;
|
EnableAddressable = enableAddressable;
|
||||||
|
LocationToLower = locationToLower;
|
||||||
|
IncludeAssetGUID = includeAssetGUID;
|
||||||
UniqueBundleName = uniqueBundleName;
|
UniqueBundleName = uniqueBundleName;
|
||||||
|
|
||||||
// 着色器统一全名称
|
// 着色器统一全名称
|
||||||
|
|
|
@ -67,6 +67,8 @@ namespace YooAsset.Editor
|
||||||
_items.Add(new ItemWrapper("包裹版本", buildReport.Summary.BuildPackageVersion));
|
_items.Add(new ItemWrapper("包裹版本", buildReport.Summary.BuildPackageVersion));
|
||||||
|
|
||||||
_items.Add(new ItemWrapper("启用可寻址资源定位", $"{buildReport.Summary.EnableAddressable}"));
|
_items.Add(new ItemWrapper("启用可寻址资源定位", $"{buildReport.Summary.EnableAddressable}"));
|
||||||
|
_items.Add(new ItemWrapper("资源定位地址大小写不敏感", $"{buildReport.Summary.LocationToLower}"));
|
||||||
|
_items.Add(new ItemWrapper("包含资源GUID数据", $"{buildReport.Summary.IncludeAssetGUID}"));
|
||||||
_items.Add(new ItemWrapper("资源包名唯一化", $"{buildReport.Summary.UniqueBundleName}"));
|
_items.Add(new ItemWrapper("资源包名唯一化", $"{buildReport.Summary.UniqueBundleName}"));
|
||||||
_items.Add(new ItemWrapper("自动分析冗余资源", $"{buildReport.Summary.AutoAnalyzeRedundancy}"));
|
_items.Add(new ItemWrapper("自动分析冗余资源", $"{buildReport.Summary.AutoAnalyzeRedundancy}"));
|
||||||
_items.Add(new ItemWrapper("共享资源的打包类名称", buildReport.Summary.ShareAssetPackRuleClassName));
|
_items.Add(new ItemWrapper("共享资源的打包类名称", buildReport.Summary.ShareAssetPackRuleClassName));
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace YooAsset
|
|
||||||
{
|
|
||||||
public class AssetReference
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -27,12 +27,6 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class InitializeParameters
|
public abstract class InitializeParameters
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// 资源定位地址大小写不敏感
|
|
||||||
/// 注意:默认值为False
|
|
||||||
/// </summary>
|
|
||||||
public bool LocationToLower = false;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文件解密服务接口
|
/// 文件解密服务接口
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -36,6 +36,8 @@ namespace YooAsset
|
||||||
|
|
||||||
// 写入文件头信息
|
// 写入文件头信息
|
||||||
buffer.WriteBool(manifest.EnableAddressable);
|
buffer.WriteBool(manifest.EnableAddressable);
|
||||||
|
buffer.WriteBool(manifest.LocationToLower);
|
||||||
|
buffer.WriteBool(manifest.IncludeAssetGUID);
|
||||||
buffer.WriteInt32(manifest.OutputNameStyle);
|
buffer.WriteInt32(manifest.OutputNameStyle);
|
||||||
buffer.WriteUTF8(manifest.PackageName);
|
buffer.WriteUTF8(manifest.PackageName);
|
||||||
buffer.WriteUTF8(manifest.PackageVersion);
|
buffer.WriteUTF8(manifest.PackageVersion);
|
||||||
|
@ -47,6 +49,7 @@ namespace YooAsset
|
||||||
var packageAsset = manifest.AssetList[i];
|
var packageAsset = manifest.AssetList[i];
|
||||||
buffer.WriteUTF8(packageAsset.Address);
|
buffer.WriteUTF8(packageAsset.Address);
|
||||||
buffer.WriteUTF8(packageAsset.AssetPath);
|
buffer.WriteUTF8(packageAsset.AssetPath);
|
||||||
|
buffer.WriteUTF8(packageAsset.AssetGUID);
|
||||||
buffer.WriteUTF8Array(packageAsset.AssetTags);
|
buffer.WriteUTF8Array(packageAsset.AssetTags);
|
||||||
buffer.WriteInt32(packageAsset.BundleID);
|
buffer.WriteInt32(packageAsset.BundleID);
|
||||||
buffer.WriteInt32Array(packageAsset.DependIDs);
|
buffer.WriteInt32Array(packageAsset.DependIDs);
|
||||||
|
@ -104,10 +107,16 @@ namespace YooAsset
|
||||||
// 读取文件头信息
|
// 读取文件头信息
|
||||||
manifest.FileVersion = fileVersion;
|
manifest.FileVersion = fileVersion;
|
||||||
manifest.EnableAddressable = buffer.ReadBool();
|
manifest.EnableAddressable = buffer.ReadBool();
|
||||||
|
manifest.LocationToLower = buffer.ReadBool();
|
||||||
|
manifest.IncludeAssetGUID = buffer.ReadBool();
|
||||||
manifest.OutputNameStyle = buffer.ReadInt32();
|
manifest.OutputNameStyle = buffer.ReadInt32();
|
||||||
manifest.PackageName = buffer.ReadUTF8();
|
manifest.PackageName = buffer.ReadUTF8();
|
||||||
manifest.PackageVersion = buffer.ReadUTF8();
|
manifest.PackageVersion = buffer.ReadUTF8();
|
||||||
|
|
||||||
|
// 检测配置
|
||||||
|
if (manifest.EnableAddressable && manifest.LocationToLower)
|
||||||
|
throw new Exception("Addressable not support location to lower !");
|
||||||
|
|
||||||
// 读取资源列表
|
// 读取资源列表
|
||||||
int packageAssetCount = buffer.ReadInt32();
|
int packageAssetCount = buffer.ReadInt32();
|
||||||
manifest.AssetList = new List<PackageAsset>(packageAssetCount);
|
manifest.AssetList = new List<PackageAsset>(packageAssetCount);
|
||||||
|
@ -116,6 +125,7 @@ namespace YooAsset
|
||||||
var packageAsset = new PackageAsset();
|
var packageAsset = new PackageAsset();
|
||||||
packageAsset.Address = buffer.ReadUTF8();
|
packageAsset.Address = buffer.ReadUTF8();
|
||||||
packageAsset.AssetPath = buffer.ReadUTF8();
|
packageAsset.AssetPath = buffer.ReadUTF8();
|
||||||
|
packageAsset.AssetGUID = buffer.ReadUTF8();
|
||||||
packageAsset.AssetTags = buffer.ReadUTF8Array();
|
packageAsset.AssetTags = buffer.ReadUTF8Array();
|
||||||
packageAsset.BundleID = buffer.ReadInt32();
|
packageAsset.BundleID = buffer.ReadInt32();
|
||||||
packageAsset.DependIDs = buffer.ReadInt32Array();
|
packageAsset.DependIDs = buffer.ReadInt32Array();
|
||||||
|
@ -140,7 +150,7 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// BundleDic
|
// 填充BundleDic
|
||||||
manifest.BundleDic = new Dictionary<string, PackageBundle>(manifest.BundleList.Count);
|
manifest.BundleDic = new Dictionary<string, PackageBundle>(manifest.BundleList.Count);
|
||||||
foreach (var packageBundle in manifest.BundleList)
|
foreach (var packageBundle in manifest.BundleList)
|
||||||
{
|
{
|
||||||
|
@ -148,7 +158,7 @@ namespace YooAsset
|
||||||
manifest.BundleDic.Add(packageBundle.BundleName, packageBundle);
|
manifest.BundleDic.Add(packageBundle.BundleName, packageBundle);
|
||||||
}
|
}
|
||||||
|
|
||||||
// AssetDic
|
// 填充AssetDic
|
||||||
manifest.AssetDic = new Dictionary<string, PackageAsset>(manifest.AssetList.Count);
|
manifest.AssetDic = new Dictionary<string, PackageAsset>(manifest.AssetList.Count);
|
||||||
foreach (var packageAsset in manifest.AssetList)
|
foreach (var packageAsset in manifest.AssetList)
|
||||||
{
|
{
|
||||||
|
|
|
@ -77,10 +77,16 @@ namespace YooAsset
|
||||||
Manifest = new PackageManifest();
|
Manifest = new PackageManifest();
|
||||||
Manifest.FileVersion = fileVersion;
|
Manifest.FileVersion = fileVersion;
|
||||||
Manifest.EnableAddressable = _buffer.ReadBool();
|
Manifest.EnableAddressable = _buffer.ReadBool();
|
||||||
|
Manifest.LocationToLower = _buffer.ReadBool();
|
||||||
|
Manifest.IncludeAssetGUID = _buffer.ReadBool();
|
||||||
Manifest.OutputNameStyle = _buffer.ReadInt32();
|
Manifest.OutputNameStyle = _buffer.ReadInt32();
|
||||||
Manifest.PackageName = _buffer.ReadUTF8();
|
Manifest.PackageName = _buffer.ReadUTF8();
|
||||||
Manifest.PackageVersion = _buffer.ReadUTF8();
|
Manifest.PackageVersion = _buffer.ReadUTF8();
|
||||||
|
|
||||||
|
// 检测配置
|
||||||
|
if (Manifest.EnableAddressable && Manifest.LocationToLower)
|
||||||
|
throw new System.Exception("Addressable not support location to lower !");
|
||||||
|
|
||||||
_steps = ESteps.PrepareAssetList;
|
_steps = ESteps.PrepareAssetList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,6 +95,17 @@ namespace YooAsset
|
||||||
_packageAssetCount = _buffer.ReadInt32();
|
_packageAssetCount = _buffer.ReadInt32();
|
||||||
Manifest.AssetList = new List<PackageAsset>(_packageAssetCount);
|
Manifest.AssetList = new List<PackageAsset>(_packageAssetCount);
|
||||||
Manifest.AssetDic = new Dictionary<string, PackageAsset>(_packageAssetCount);
|
Manifest.AssetDic = new Dictionary<string, PackageAsset>(_packageAssetCount);
|
||||||
|
|
||||||
|
if (Manifest.EnableAddressable)
|
||||||
|
Manifest.AssetPathMapping1 = new Dictionary<string, string>(_packageAssetCount);
|
||||||
|
else
|
||||||
|
Manifest.AssetPathMapping1 = new Dictionary<string, string>(_packageAssetCount * 2);
|
||||||
|
|
||||||
|
if (Manifest.IncludeAssetGUID)
|
||||||
|
Manifest.AssetPathMapping2 = new Dictionary<string, string>(_packageAssetCount);
|
||||||
|
else
|
||||||
|
Manifest.AssetPathMapping2 = new Dictionary<string, string>();
|
||||||
|
|
||||||
_progressTotalValue = _packageAssetCount;
|
_progressTotalValue = _packageAssetCount;
|
||||||
_steps = ESteps.DeserializeAssetList;
|
_steps = ESteps.DeserializeAssetList;
|
||||||
}
|
}
|
||||||
|
@ -99,6 +116,7 @@ namespace YooAsset
|
||||||
var packageAsset = new PackageAsset();
|
var packageAsset = new PackageAsset();
|
||||||
packageAsset.Address = _buffer.ReadUTF8();
|
packageAsset.Address = _buffer.ReadUTF8();
|
||||||
packageAsset.AssetPath = _buffer.ReadUTF8();
|
packageAsset.AssetPath = _buffer.ReadUTF8();
|
||||||
|
packageAsset.AssetGUID = _buffer.ReadUTF8();
|
||||||
packageAsset.AssetTags = _buffer.ReadUTF8Array();
|
packageAsset.AssetTags = _buffer.ReadUTF8Array();
|
||||||
packageAsset.BundleID = _buffer.ReadInt32();
|
packageAsset.BundleID = _buffer.ReadInt32();
|
||||||
packageAsset.DependIDs = _buffer.ReadInt32Array();
|
packageAsset.DependIDs = _buffer.ReadInt32Array();
|
||||||
|
@ -111,6 +129,47 @@ namespace YooAsset
|
||||||
else
|
else
|
||||||
Manifest.AssetDic.Add(assetPath, packageAsset);
|
Manifest.AssetDic.Add(assetPath, packageAsset);
|
||||||
|
|
||||||
|
// 填充AssetPathMapping1
|
||||||
|
if (Manifest.EnableAddressable)
|
||||||
|
{
|
||||||
|
string location = packageAsset.Address;
|
||||||
|
if (Manifest.AssetPathMapping1.ContainsKey(location))
|
||||||
|
throw new System.Exception($"Address have existed : {location}");
|
||||||
|
else
|
||||||
|
Manifest.AssetPathMapping1.Add(location, packageAsset.AssetPath);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string location = packageAsset.AssetPath;
|
||||||
|
if (Manifest.LocationToLower)
|
||||||
|
location = location.ToLower();
|
||||||
|
|
||||||
|
// 添加原生路径的映射
|
||||||
|
if (Manifest.AssetPathMapping1.ContainsKey(location))
|
||||||
|
throw new System.Exception($"AssetPath have existed : {location}");
|
||||||
|
else
|
||||||
|
Manifest.AssetPathMapping1.Add(location, packageAsset.AssetPath);
|
||||||
|
|
||||||
|
// 添加无后缀名路径的映射
|
||||||
|
if (Path.HasExtension(location))
|
||||||
|
{
|
||||||
|
string locationWithoutExtension = PathUtility.RemoveExtension(location);
|
||||||
|
if (Manifest.AssetPathMapping1.ContainsKey(locationWithoutExtension))
|
||||||
|
YooLogger.Warning($"AssetPath have existed : {locationWithoutExtension}");
|
||||||
|
else
|
||||||
|
Manifest.AssetPathMapping1.Add(locationWithoutExtension, packageAsset.AssetPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 填充AssetPathMapping2
|
||||||
|
if (Manifest.IncludeAssetGUID)
|
||||||
|
{
|
||||||
|
if (Manifest.AssetPathMapping2.ContainsKey(packageAsset.AssetGUID))
|
||||||
|
throw new System.Exception($"AssetGUID have existed : {packageAsset.AssetGUID}");
|
||||||
|
else
|
||||||
|
Manifest.AssetPathMapping2.Add(packageAsset.AssetGUID, packageAsset.AssetPath);
|
||||||
|
}
|
||||||
|
|
||||||
_packageAssetCount--;
|
_packageAssetCount--;
|
||||||
Progress = 1f - _packageAssetCount / _progressTotalValue;
|
Progress = 1f - _packageAssetCount / _progressTotalValue;
|
||||||
if (OperationSystem.IsBusy)
|
if (OperationSystem.IsBusy)
|
||||||
|
|
|
@ -16,6 +16,11 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string AssetPath;
|
public string AssetPath;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资源GUID
|
||||||
|
/// </summary>
|
||||||
|
public string AssetGUID;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源的分类标签
|
/// 资源的分类标签
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -22,6 +22,16 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool EnableAddressable;
|
public bool EnableAddressable;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资源定位地址大小写不敏感
|
||||||
|
/// </summary>
|
||||||
|
public bool LocationToLower;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 包含资源GUID数据
|
||||||
|
/// </summary>
|
||||||
|
public bool IncludeAssetGUID;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文件名称样式
|
/// 文件名称样式
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -61,93 +71,17 @@ namespace YooAsset
|
||||||
public Dictionary<string, PackageAsset> AssetDic;
|
public Dictionary<string, PackageAsset> AssetDic;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源路径映射集合
|
/// 资源路径映射集合(提供Location获取AssetPath)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[NonSerialized]
|
[NonSerialized]
|
||||||
public Dictionary<string, string> AssetPathMapping;
|
public Dictionary<string, string> AssetPathMapping1;
|
||||||
|
|
||||||
// 资源路径映射相关
|
|
||||||
private bool _isInitAssetPathMapping = false;
|
|
||||||
private bool _locationToLower = false;
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 初始化资源路径映射
|
/// 资源路径映射集合(提供AssetGUID获取AssetPath)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void InitAssetPathMapping(bool locationToLower)
|
[NonSerialized]
|
||||||
{
|
public Dictionary<string, string> AssetPathMapping2;
|
||||||
if (_isInitAssetPathMapping)
|
|
||||||
return;
|
|
||||||
_isInitAssetPathMapping = true;
|
|
||||||
|
|
||||||
if (EnableAddressable)
|
|
||||||
{
|
|
||||||
if (locationToLower)
|
|
||||||
YooLogger.Error("Addressable not support location to lower !");
|
|
||||||
|
|
||||||
AssetPathMapping = new Dictionary<string, string>(AssetList.Count);
|
|
||||||
foreach (var packageAsset in AssetList)
|
|
||||||
{
|
|
||||||
string location = packageAsset.Address;
|
|
||||||
if (AssetPathMapping.ContainsKey(location))
|
|
||||||
throw new Exception($"Address have existed : {location}");
|
|
||||||
else
|
|
||||||
AssetPathMapping.Add(location, packageAsset.AssetPath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_locationToLower = locationToLower;
|
|
||||||
AssetPathMapping = new Dictionary<string, string>(AssetList.Count * 2);
|
|
||||||
foreach (var packageAsset in AssetList)
|
|
||||||
{
|
|
||||||
string location = packageAsset.AssetPath;
|
|
||||||
if (locationToLower)
|
|
||||||
location = location.ToLower();
|
|
||||||
|
|
||||||
// 添加原生路径的映射
|
|
||||||
if (AssetPathMapping.ContainsKey(location))
|
|
||||||
throw new Exception($"AssetPath have existed : {location}");
|
|
||||||
else
|
|
||||||
AssetPathMapping.Add(location, packageAsset.AssetPath);
|
|
||||||
|
|
||||||
// 添加无后缀名路径的映射
|
|
||||||
if (Path.HasExtension(location))
|
|
||||||
{
|
|
||||||
string locationWithoutExtension = PathUtility.RemoveExtension(location);
|
|
||||||
if (AssetPathMapping.ContainsKey(locationWithoutExtension))
|
|
||||||
YooLogger.Warning($"AssetPath have existed : {locationWithoutExtension}");
|
|
||||||
else
|
|
||||||
AssetPathMapping.Add(locationWithoutExtension, packageAsset.AssetPath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 映射为资源路径
|
|
||||||
/// </summary>
|
|
||||||
public string MappingToAssetPath(string location)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(location))
|
|
||||||
{
|
|
||||||
YooLogger.Error("Failed to mapping location to asset path, The location is null or empty.");
|
|
||||||
return string.Empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_locationToLower)
|
|
||||||
location = location.ToLower();
|
|
||||||
|
|
||||||
if (AssetPathMapping.TryGetValue(location, out string assetPath))
|
|
||||||
{
|
|
||||||
return assetPath;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
YooLogger.Warning($"Failed to mapping location to asset path : {location}");
|
|
||||||
return string.Empty;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 尝试映射为资源路径
|
/// 尝试映射为资源路径
|
||||||
|
@ -157,10 +91,10 @@ namespace YooAsset
|
||||||
if (string.IsNullOrEmpty(location))
|
if (string.IsNullOrEmpty(location))
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
|
|
||||||
if (_locationToLower)
|
if (LocationToLower)
|
||||||
location = location.ToLower();
|
location = location.ToLower();
|
||||||
|
|
||||||
if (AssetPathMapping.TryGetValue(location, out string assetPath))
|
if (AssetPathMapping1.TryGetValue(location, out string assetPath))
|
||||||
return assetPath;
|
return assetPath;
|
||||||
else
|
else
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
|
@ -283,14 +217,14 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源定位地址转换为资源信息类,失败时内部会发出错误日志。
|
/// 资源定位地址转换为资源信息。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>如果转换失败会返回一个无效的资源信息类</returns>
|
/// <returns>如果转换失败会返回一个无效的资源信息类</returns>
|
||||||
public AssetInfo ConvertLocationToAssetInfo(string location, System.Type assetType)
|
public AssetInfo ConvertLocationToAssetInfo(string location, System.Type assetType)
|
||||||
{
|
{
|
||||||
DebugCheckLocation(location);
|
DebugCheckLocation(location);
|
||||||
|
|
||||||
string assetPath = MappingToAssetPath(location);
|
string assetPath = ConvertLocationToAssetInfoMapping(location);
|
||||||
if (TryGetPackageAsset(assetPath, out PackageAsset packageAsset))
|
if (TryGetPackageAsset(assetPath, out PackageAsset packageAsset))
|
||||||
{
|
{
|
||||||
AssetInfo assetInfo = new AssetInfo(packageAsset, assetType);
|
AssetInfo assetInfo = new AssetInfo(packageAsset, assetType);
|
||||||
|
@ -307,6 +241,76 @@ namespace YooAsset
|
||||||
return assetInfo;
|
return assetInfo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private string ConvertLocationToAssetInfoMapping(string location)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(location))
|
||||||
|
{
|
||||||
|
YooLogger.Error("Failed to mapping location to asset path, The location is null or empty.");
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (LocationToLower)
|
||||||
|
location = location.ToLower();
|
||||||
|
|
||||||
|
if (AssetPathMapping1.TryGetValue(location, out string assetPath))
|
||||||
|
{
|
||||||
|
return assetPath;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
YooLogger.Warning($"Failed to mapping location to asset path : {location}");
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资源GUID转换为资源信息。
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>如果转换失败会返回一个无效的资源信息类</returns>
|
||||||
|
public AssetInfo ConvertAssetGUIDToAssetInfo(string assetGUID, System.Type assetType)
|
||||||
|
{
|
||||||
|
if (IncludeAssetGUID == false)
|
||||||
|
{
|
||||||
|
YooLogger.Warning("Package manifest not include asset guid ! Please check asset bundle collector settings.");
|
||||||
|
AssetInfo assetInfo = new AssetInfo("AssetGUID data is empty !");
|
||||||
|
return assetInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
string assetPath = ConvertAssetGUIDToAssetInfoMapping(assetGUID);
|
||||||
|
if (TryGetPackageAsset(assetPath, out PackageAsset packageAsset))
|
||||||
|
{
|
||||||
|
AssetInfo assetInfo = new AssetInfo(packageAsset, assetType);
|
||||||
|
return assetInfo;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string error;
|
||||||
|
if (string.IsNullOrEmpty(assetGUID))
|
||||||
|
error = $"The assetGUID is null or empty !";
|
||||||
|
else
|
||||||
|
error = $"The assetGUID is invalid : {assetGUID}";
|
||||||
|
AssetInfo assetInfo = new AssetInfo(error);
|
||||||
|
return assetInfo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private string ConvertAssetGUIDToAssetInfoMapping(string assetGUID)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(assetGUID))
|
||||||
|
{
|
||||||
|
YooLogger.Error("Failed to mapping assetGUID to asset path, The assetGUID is null or empty.");
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (AssetPathMapping2.TryGetValue(assetGUID, out string assetPath))
|
||||||
|
{
|
||||||
|
return assetPath;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
YooLogger.Warning($"Failed to mapping assetGUID to asset path : {assetGUID}");
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取资源包内的主资源列表
|
/// 获取资源包内的主资源列表
|
||||||
|
|
|
@ -7,14 +7,12 @@ namespace YooAsset
|
||||||
internal class EditorSimulateModeImpl : IPlayModeServices, IBundleServices
|
internal class EditorSimulateModeImpl : IPlayModeServices, IBundleServices
|
||||||
{
|
{
|
||||||
private PackageManifest _activeManifest;
|
private PackageManifest _activeManifest;
|
||||||
private bool _locationToLower;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 异步初始化
|
/// 异步初始化
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public InitializationOperation InitializeAsync(bool locationToLower, string simulateManifestFilePath)
|
public InitializationOperation InitializeAsync(string simulateManifestFilePath)
|
||||||
{
|
{
|
||||||
_locationToLower = locationToLower;
|
|
||||||
var operation = new EditorSimulateModeInitializationOperation(this, simulateManifestFilePath);
|
var operation = new EditorSimulateModeInitializationOperation(this, simulateManifestFilePath);
|
||||||
OperationSystem.StartOperation(operation);
|
OperationSystem.StartOperation(operation);
|
||||||
return operation;
|
return operation;
|
||||||
|
@ -26,7 +24,6 @@ namespace YooAsset
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
_activeManifest = value;
|
_activeManifest = value;
|
||||||
_activeManifest.InitAssetPathMapping(_locationToLower);
|
|
||||||
}
|
}
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,7 +10,6 @@ namespace YooAsset
|
||||||
|
|
||||||
// 参数相关
|
// 参数相关
|
||||||
private string _packageName;
|
private string _packageName;
|
||||||
private bool _locationToLower;
|
|
||||||
private string _defaultHostServer;
|
private string _defaultHostServer;
|
||||||
private string _fallbackHostServer;
|
private string _fallbackHostServer;
|
||||||
private IQueryServices _queryServices;
|
private IQueryServices _queryServices;
|
||||||
|
@ -18,10 +17,9 @@ namespace YooAsset
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 异步初始化
|
/// 异步初始化
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public InitializationOperation InitializeAsync(string packageName, bool locationToLower, string defaultHostServer, string fallbackHostServer, IQueryServices queryServices)
|
public InitializationOperation InitializeAsync(string packageName, string defaultHostServer, string fallbackHostServer, IQueryServices queryServices)
|
||||||
{
|
{
|
||||||
_packageName = packageName;
|
_packageName = packageName;
|
||||||
_locationToLower = locationToLower;
|
|
||||||
_defaultHostServer = defaultHostServer;
|
_defaultHostServer = defaultHostServer;
|
||||||
_fallbackHostServer = fallbackHostServer;
|
_fallbackHostServer = fallbackHostServer;
|
||||||
_queryServices = queryServices;
|
_queryServices = queryServices;
|
||||||
|
@ -67,7 +65,6 @@ namespace YooAsset
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
_activeManifest = value;
|
_activeManifest = value;
|
||||||
_activeManifest.InitAssetPathMapping(_locationToLower);
|
|
||||||
}
|
}
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
|
|
@ -7,14 +7,12 @@ namespace YooAsset
|
||||||
internal class OfflinePlayModeImpl : IPlayModeServices, IBundleServices
|
internal class OfflinePlayModeImpl : IPlayModeServices, IBundleServices
|
||||||
{
|
{
|
||||||
private PackageManifest _activeManifest;
|
private PackageManifest _activeManifest;
|
||||||
private bool _locationToLower;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 异步初始化
|
/// 异步初始化
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public InitializationOperation InitializeAsync(string packageName, bool locationToLower)
|
public InitializationOperation InitializeAsync(string packageName)
|
||||||
{
|
{
|
||||||
_locationToLower = locationToLower;
|
|
||||||
var operation = new OfflinePlayModeInitializationOperation(this, packageName);
|
var operation = new OfflinePlayModeInitializationOperation(this, packageName);
|
||||||
OperationSystem.StartOperation(operation);
|
OperationSystem.StartOperation(operation);
|
||||||
return operation;
|
return operation;
|
||||||
|
@ -26,7 +24,6 @@ namespace YooAsset
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
_activeManifest = value;
|
_activeManifest = value;
|
||||||
_activeManifest.InitAssetPathMapping(_locationToLower);
|
|
||||||
}
|
}
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
|
|
@ -92,7 +92,7 @@ namespace YooAsset
|
||||||
parameters.DecryptionServices, _bundleServices);
|
parameters.DecryptionServices, _bundleServices);
|
||||||
|
|
||||||
var initializeParameters = parameters as EditorSimulateModeParameters;
|
var initializeParameters = parameters as EditorSimulateModeParameters;
|
||||||
initializeOperation = editorSimulateModeImpl.InitializeAsync(initializeParameters.LocationToLower, initializeParameters.SimulateManifestFilePath);
|
initializeOperation = editorSimulateModeImpl.InitializeAsync(initializeParameters.SimulateManifestFilePath);
|
||||||
}
|
}
|
||||||
else if (_playMode == EPlayMode.OfflinePlayMode)
|
else if (_playMode == EPlayMode.OfflinePlayMode)
|
||||||
{
|
{
|
||||||
|
@ -104,7 +104,7 @@ namespace YooAsset
|
||||||
parameters.DecryptionServices, _bundleServices);
|
parameters.DecryptionServices, _bundleServices);
|
||||||
|
|
||||||
var initializeParameters = parameters as OfflinePlayModeParameters;
|
var initializeParameters = parameters as OfflinePlayModeParameters;
|
||||||
initializeOperation = offlinePlayModeImpl.InitializeAsync(PackageName, initializeParameters.LocationToLower);
|
initializeOperation = offlinePlayModeImpl.InitializeAsync(PackageName);
|
||||||
}
|
}
|
||||||
else if (_playMode == EPlayMode.HostPlayMode)
|
else if (_playMode == EPlayMode.HostPlayMode)
|
||||||
{
|
{
|
||||||
|
@ -118,7 +118,6 @@ namespace YooAsset
|
||||||
var initializeParameters = parameters as HostPlayModeParameters;
|
var initializeParameters = parameters as HostPlayModeParameters;
|
||||||
initializeOperation = hostPlayModeImpl.InitializeAsync(
|
initializeOperation = hostPlayModeImpl.InitializeAsync(
|
||||||
PackageName,
|
PackageName,
|
||||||
initializeParameters.LocationToLower,
|
|
||||||
initializeParameters.DefaultHostServer,
|
initializeParameters.DefaultHostServer,
|
||||||
initializeParameters.FallbackHostServer,
|
initializeParameters.FallbackHostServer,
|
||||||
initializeParameters.QueryServices
|
initializeParameters.QueryServices
|
||||||
|
@ -363,8 +362,17 @@ namespace YooAsset
|
||||||
public AssetInfo GetAssetInfo(string location)
|
public AssetInfo GetAssetInfo(string location)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, null);
|
return ConvertLocationToAssetInfo(location, null);
|
||||||
return assetInfo;
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取资源信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="assetGUID">资源GUID</param>
|
||||||
|
public AssetInfo GetAssetInfoByGUID(string assetGUID)
|
||||||
|
{
|
||||||
|
DebugCheckInitialize();
|
||||||
|
return ConvertAssetGUIDToAssetInfo(assetGUID, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -889,13 +897,14 @@ namespace YooAsset
|
||||||
return _playModeServices.ActiveManifest.IsIncludeBundleFile(cacheGUID);
|
return _playModeServices.ActiveManifest.IsIncludeBundleFile(cacheGUID);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 资源定位地址转换为资源信息类
|
|
||||||
/// </summary>
|
|
||||||
private AssetInfo ConvertLocationToAssetInfo(string location, System.Type assetType)
|
private AssetInfo ConvertLocationToAssetInfo(string location, System.Type assetType)
|
||||||
{
|
{
|
||||||
return _playModeServices.ActiveManifest.ConvertLocationToAssetInfo(location, assetType);
|
return _playModeServices.ActiveManifest.ConvertLocationToAssetInfo(location, assetType);
|
||||||
}
|
}
|
||||||
|
private AssetInfo ConvertAssetGUIDToAssetInfo(string assetGUID, System.Type assetType)
|
||||||
|
{
|
||||||
|
return _playModeServices.ActiveManifest.ConvertAssetGUIDToAssetInfo(assetGUID, assetType);
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 调试方法
|
#region 调试方法
|
||||||
|
|
|
@ -24,7 +24,7 @@ namespace YooAsset
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 清单文件格式版本
|
/// 清单文件格式版本
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string ManifestFileVersion = "1.4.6";
|
public const string ManifestFileVersion = "1.4.17";
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -0,0 +1,73 @@
|
||||||
|
using UnityEngine;
|
||||||
|
using YooAsset;
|
||||||
|
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
[UnityEditor.CustomEditor(typeof(GameObjectAssetReference), true)]
|
||||||
|
public class GameObjectAssetReferenceInspector : UnityEditor.Editor
|
||||||
|
{
|
||||||
|
private bool _init = false;
|
||||||
|
private GameObject _cacheObject;
|
||||||
|
|
||||||
|
public override void OnInspectorGUI()
|
||||||
|
{
|
||||||
|
GameObjectAssetReference mono = (GameObjectAssetReference)target;
|
||||||
|
|
||||||
|
if (_init == false)
|
||||||
|
{
|
||||||
|
_init = true;
|
||||||
|
if (string.IsNullOrEmpty(mono.AssetGUID) == false)
|
||||||
|
{
|
||||||
|
string assetPath = UnityEditor.AssetDatabase.GUIDToAssetPath(mono.AssetGUID);
|
||||||
|
if (string.IsNullOrEmpty(assetPath) == false)
|
||||||
|
{
|
||||||
|
_cacheObject = UnityEditor.AssetDatabase.LoadAssetAtPath<GameObject>(assetPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GameObject go = (GameObject)UnityEditor.EditorGUILayout.ObjectField(_cacheObject, typeof(GameObject), false);
|
||||||
|
if (go != _cacheObject)
|
||||||
|
{
|
||||||
|
_cacheObject = go;
|
||||||
|
string assetPath = UnityEditor.AssetDatabase.GetAssetPath(go);
|
||||||
|
mono.AssetGUID = UnityEditor.AssetDatabase.AssetPathToGUID(assetPath);
|
||||||
|
UnityEditor.EditorUtility.SetDirty(target);
|
||||||
|
}
|
||||||
|
|
||||||
|
UnityEditor.EditorGUILayout.LabelField("Asset GUID", mono.AssetGUID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
public class GameObjectAssetReference : MonoBehaviour
|
||||||
|
{
|
||||||
|
[HideInInspector]
|
||||||
|
public string AssetGUID = "";
|
||||||
|
|
||||||
|
private AssetOperationHandle _handle;
|
||||||
|
|
||||||
|
public void Start()
|
||||||
|
{
|
||||||
|
var package = YooAssets.GetPackage("DefaultPackage");
|
||||||
|
var assetInfo = package.GetAssetInfoByGUID(AssetGUID);
|
||||||
|
_handle = package.LoadAssetAsync(assetInfo);
|
||||||
|
_handle.Completed += Handle_Completed;
|
||||||
|
}
|
||||||
|
public void OnDestroy()
|
||||||
|
{
|
||||||
|
if (_handle != null)
|
||||||
|
{
|
||||||
|
_handle.Release();
|
||||||
|
_handle = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Handle_Completed(AssetOperationHandle handle)
|
||||||
|
{
|
||||||
|
if (handle.Status == EOperationStatus.Succeed)
|
||||||
|
{
|
||||||
|
handle.InstantiateSync(this.transform);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue