mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-21 16:00:32 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fb743ada63 | ||
|
|
a17e742218 | ||
|
|
d6b54dd49c | ||
|
|
b7a20d4bdb | ||
|
|
28c22694ba | ||
|
|
efd0789e09 |
@@ -2,6 +2,17 @@
|
|||||||
|
|
||||||
All notable changes to this package will be documented in this file.
|
All notable changes to this package will be documented in this file.
|
||||||
|
|
||||||
|
## [1.0.2] - 2022-04-07
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- 修复在资源加载完成回调内释放自身资源句柄时的异常报错。
|
||||||
|
- 修复了资源分组在特殊情况下打包报错的问题。
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- StreamingAssets目录下增加了用于存放打包资源的总文件夹
|
||||||
|
|
||||||
## [1.0.1] - 2022-04-07
|
## [1.0.1] - 2022-04-07
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|||||||
@@ -17,6 +17,14 @@ namespace YooAsset.Editor
|
|||||||
return $"{projectPath}/Bundles";
|
return $"{projectPath}/Bundles";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取流文件夹路径
|
||||||
|
/// </summary>
|
||||||
|
public static string GetStreamingAssetsFolderPath()
|
||||||
|
{
|
||||||
|
return $"{Application.dataPath}/StreamingAssets/YooAssets/";
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取构建管线的输出目录
|
/// 获取构建管线的输出目录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -30,8 +38,8 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static void ClearStreamingAssetsFolder()
|
public static void ClearStreamingAssetsFolder()
|
||||||
{
|
{
|
||||||
string streamingPath = Application.dataPath + "/StreamingAssets";
|
string streamingFolderPath = GetStreamingAssetsFolderPath();
|
||||||
EditorTools.ClearFolder(streamingPath);
|
EditorTools.ClearFolder(streamingFolderPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -40,17 +48,17 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static void DeleteStreamingAssetsIgnoreFiles()
|
public static void DeleteStreamingAssetsIgnoreFiles()
|
||||||
{
|
{
|
||||||
string streamingPath = Application.dataPath + "/StreamingAssets";
|
string streamingFolderPath = GetStreamingAssetsFolderPath();
|
||||||
if (Directory.Exists(streamingPath))
|
if (Directory.Exists(streamingFolderPath))
|
||||||
{
|
{
|
||||||
string[] files = Directory.GetFiles(streamingPath, "*.manifest", SearchOption.AllDirectories);
|
string[] files = Directory.GetFiles(streamingFolderPath, "*.manifest", SearchOption.AllDirectories);
|
||||||
foreach (var file in files)
|
foreach (var file in files)
|
||||||
{
|
{
|
||||||
FileInfo info = new FileInfo(file);
|
FileInfo info = new FileInfo(file);
|
||||||
info.Delete();
|
info.Delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
files = Directory.GetFiles(streamingPath, "*.meta", SearchOption.AllDirectories);
|
files = Directory.GetFiles(streamingFolderPath, "*.meta", SearchOption.AllDirectories);
|
||||||
foreach (var item in files)
|
foreach (var item in files)
|
||||||
{
|
{
|
||||||
FileInfo info = new FileInfo(item);
|
FileInfo info = new FileInfo(item);
|
||||||
|
|||||||
@@ -89,10 +89,7 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string GetAppendExtension()
|
public string GetAppendExtension()
|
||||||
{
|
{
|
||||||
if (IsRawFile)
|
return System.IO.Path.GetExtension(BundleName);
|
||||||
return $".{YooAssetSettingsData.Setting.RawFileVariant}";
|
|
||||||
else
|
|
||||||
return $".{YooAssetSettingsData.Setting.AssetBundleFileVariant}";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ namespace YooAsset.Editor
|
|||||||
if (buildAssetInfo.BundleNameIsValid() == false)
|
if (buildAssetInfo.BundleNameIsValid() == false)
|
||||||
{
|
{
|
||||||
string bundleName = defaultPackRule.GetBundleName(new PackRuleData(buildAssetInfo.AssetPath));
|
string bundleName = defaultPackRule.GetBundleName(new PackRuleData(buildAssetInfo.AssetPath));
|
||||||
bundleName = AssetBundleCollector.RevisedBundleName(bundleName);
|
bundleName = AssetBundleCollector.RevisedBundleName(bundleName, false);
|
||||||
buildAssetInfo.SetBundleName(bundleName);
|
buildAssetInfo.SetBundleName(bundleName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ namespace YooAsset.Editor
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
string sourcePath = $"{pipelineOutputDirectory}/{patchBundle.BundleName}";
|
string sourcePath = $"{pipelineOutputDirectory}/{patchBundle.BundleName}";
|
||||||
string destPath = $"{Application.dataPath}/StreamingAssets/{patchBundle.Hash}";
|
string destPath = $"{AssetBundleBuilderHelper.GetStreamingAssetsFolderPath()}/{patchBundle.Hash}";
|
||||||
Debug.Log($"拷贝内置文件到流目录:{patchBundle.BundleName}");
|
Debug.Log($"拷贝内置文件到流目录:{patchBundle.BundleName}");
|
||||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||||
}
|
}
|
||||||
@@ -46,14 +46,14 @@ namespace YooAsset.Editor
|
|||||||
// 拷贝清单文件
|
// 拷贝清单文件
|
||||||
{
|
{
|
||||||
string sourcePath = $"{pipelineOutputDirectory}/{YooAssetSettingsData.Setting.PatchManifestFileName}";
|
string sourcePath = $"{pipelineOutputDirectory}/{YooAssetSettingsData.Setting.PatchManifestFileName}";
|
||||||
string destPath = $"{Application.dataPath}/StreamingAssets/{YooAssetSettingsData.Setting.PatchManifestFileName}";
|
string destPath = $"{AssetBundleBuilderHelper.GetStreamingAssetsFolderPath()}/{YooAssetSettingsData.Setting.PatchManifestFileName}";
|
||||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 拷贝清单哈希文件
|
// 拷贝清单哈希文件
|
||||||
{
|
{
|
||||||
string sourcePath = $"{pipelineOutputDirectory}/{YooAssetSettingsData.Setting.PatchManifestHashFileName}";
|
string sourcePath = $"{pipelineOutputDirectory}/{YooAssetSettingsData.Setting.PatchManifestHashFileName}";
|
||||||
string destPath = $"{Application.dataPath}/StreamingAssets/{YooAssetSettingsData.Setting.PatchManifestHashFileName}";
|
string destPath = $"{AssetBundleBuilderHelper.GetStreamingAssetsFolderPath()}/{YooAssetSettingsData.Setting.PatchManifestHashFileName}";
|
||||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ namespace YooAsset.Editor
|
|||||||
continue;
|
continue;
|
||||||
if (result.ContainsKey(assetPath) == false)
|
if (result.ContainsKey(assetPath) == false)
|
||||||
{
|
{
|
||||||
string bundleName = GetBundleName(grouper, assetPath);
|
string bundleName = GetBundleName(grouper, assetPath, isRawAsset);
|
||||||
List<string> assetTags = GetAssetTags(grouper);
|
List<string> assetTags = GetAssetTags(grouper);
|
||||||
var collectAssetInfo = new CollectAssetInfo(bundleName, assetPath, assetTags, isRawAsset, NotWriteToAssetList);
|
var collectAssetInfo = new CollectAssetInfo(bundleName, assetPath, assetTags, isRawAsset, NotWriteToAssetList);
|
||||||
collectAssetInfo.DependAssets = GetAllDependencies(assetPath);
|
collectAssetInfo.DependAssets = GetAllDependencies(assetPath);
|
||||||
@@ -91,7 +91,7 @@ namespace YooAsset.Editor
|
|||||||
if (isRawAsset && NotWriteToAssetList)
|
if (isRawAsset && NotWriteToAssetList)
|
||||||
UnityEngine.Debug.LogWarning($"Are you sure raw file are not write to asset list : {assetPath}");
|
UnityEngine.Debug.LogWarning($"Are you sure raw file are not write to asset list : {assetPath}");
|
||||||
|
|
||||||
string bundleName = GetBundleName(grouper, assetPath);
|
string bundleName = GetBundleName(grouper, assetPath, isRawAsset);
|
||||||
List<string> assetTags = GetAssetTags(grouper);
|
List<string> assetTags = GetAssetTags(grouper);
|
||||||
var collectAssetInfo = new CollectAssetInfo(bundleName, assetPath, assetTags, isRawAsset, NotWriteToAssetList);
|
var collectAssetInfo = new CollectAssetInfo(bundleName, assetPath, assetTags, isRawAsset, NotWriteToAssetList);
|
||||||
result.Add(assetPath, collectAssetInfo);
|
result.Add(assetPath, collectAssetInfo);
|
||||||
@@ -139,7 +139,7 @@ namespace YooAsset.Editor
|
|||||||
IFilterRule filterRuleInstance = AssetBundleGrouperSettingData.GetFilterRuleInstance(FilterRuleName);
|
IFilterRule filterRuleInstance = AssetBundleGrouperSettingData.GetFilterRuleInstance(FilterRuleName);
|
||||||
return filterRuleInstance.IsCollectAsset(new FilterRuleData(assetPath));
|
return filterRuleInstance.IsCollectAsset(new FilterRuleData(assetPath));
|
||||||
}
|
}
|
||||||
private string GetBundleName(AssetBundleGrouper grouper, string assetPath)
|
private string GetBundleName(AssetBundleGrouper grouper, string assetPath, bool isRawAsset)
|
||||||
{
|
{
|
||||||
// 如果收集全路径着色器
|
// 如果收集全路径着色器
|
||||||
if (AssetBundleGrouperSettingData.Setting.AutoCollectShaders)
|
if (AssetBundleGrouperSettingData.Setting.AutoCollectShaders)
|
||||||
@@ -147,14 +147,17 @@ namespace YooAsset.Editor
|
|||||||
System.Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
System.Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
||||||
if (assetType == typeof(UnityEngine.Shader))
|
if (assetType == typeof(UnityEngine.Shader))
|
||||||
{
|
{
|
||||||
return RevisedBundleName(AssetBundleGrouperSettingData.Setting.ShadersBundleName);
|
string bundleName = AssetBundleGrouperSettingData.Setting.ShadersBundleName;
|
||||||
|
return RevisedBundleName(bundleName, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 根据规则设置获取资源包名称
|
// 根据规则设置获取资源包名称
|
||||||
IPackRule packRuleInstance = AssetBundleGrouperSettingData.GetPackRuleInstance(PackRuleName);
|
{
|
||||||
string bundleName = packRuleInstance.GetBundleName(new PackRuleData(assetPath, CollectPath, grouper.GrouperName));
|
IPackRule packRuleInstance = AssetBundleGrouperSettingData.GetPackRuleInstance(PackRuleName);
|
||||||
return RevisedBundleName(bundleName);
|
string bundleName = packRuleInstance.GetBundleName(new PackRuleData(assetPath, CollectPath, grouper.GrouperName));
|
||||||
|
return RevisedBundleName(bundleName, isRawAsset);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
private List<string> GetAssetTags(AssetBundleGrouper grouper)
|
private List<string> GetAssetTags(AssetBundleGrouper grouper)
|
||||||
{
|
{
|
||||||
@@ -183,9 +186,18 @@ namespace YooAsset.Editor
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 修正资源包名
|
/// 修正资源包名
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string RevisedBundleName(string bundleName)
|
public static string RevisedBundleName(string bundleName, bool isRawBundle)
|
||||||
{
|
{
|
||||||
return EditorTools.GetRegularPath(bundleName).ToLower();
|
if (isRawBundle)
|
||||||
|
{
|
||||||
|
string fullName = $"{bundleName}.{YooAssetSettingsData.Setting.RawFileVariant}";
|
||||||
|
return EditorTools.GetRegularPath(fullName).ToLower();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string fullName = $"{bundleName}.{YooAssetSettingsData.Setting.AssetBundleFileVariant}";
|
||||||
|
return EditorTools.GetRegularPath(fullName).ToLower(); ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11,10 +11,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
internal override void InvokeCallback()
|
internal override void InvokeCallback()
|
||||||
{
|
{
|
||||||
if (IsValid)
|
_callback?.Invoke(this);
|
||||||
{
|
|
||||||
_callback?.Invoke(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -11,10 +11,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
internal override void InvokeCallback()
|
internal override void InvokeCallback()
|
||||||
{
|
{
|
||||||
if (IsValid)
|
_callback?.Invoke(this);
|
||||||
{
|
|
||||||
_callback?.Invoke(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -10,10 +10,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
internal override void InvokeCallback()
|
internal override void InvokeCallback()
|
||||||
{
|
{
|
||||||
if (IsValid)
|
_callback?.Invoke(this);
|
||||||
{
|
|
||||||
_callback?.Invoke(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -224,9 +224,14 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
protected void InvokeCompletion()
|
protected void InvokeCompletion()
|
||||||
{
|
{
|
||||||
foreach (var handle in _handles)
|
// 注意:创建临时列表是为了防止外部逻辑在回调函数内创建或者释放资源句柄。
|
||||||
|
List<OperationHandleBase> tempers = new List<OperationHandleBase>(_handles);
|
||||||
|
foreach (var hande in tempers)
|
||||||
{
|
{
|
||||||
handle.InvokeCallback();
|
if (hande.IsValid)
|
||||||
|
{
|
||||||
|
hande.InvokeCallback();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_waitHandle?.Set();
|
_waitHandle?.Set();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static string MakeStreamingLoadPath(string path)
|
public static string MakeStreamingLoadPath(string path)
|
||||||
{
|
{
|
||||||
return StringUtility.Format("{0}/{1}", UnityEngine.Application.streamingAssetsPath, path);
|
return StringUtility.Format("{0}/YooAssets/{1}", UnityEngine.Application.streamingAssetsPath, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "com.tuyoogame.yooasset",
|
"name": "com.tuyoogame.yooasset",
|
||||||
"displayName": "YooAsset",
|
"displayName": "YooAsset",
|
||||||
"version": "1.0.0",
|
"version": "1.0.2",
|
||||||
"unity": "2019.4",
|
"unity": "2019.4",
|
||||||
"description": "unity3d resources management system",
|
"description": "unity3d resources management system",
|
||||||
"author": {
|
"author": {
|
||||||
|
|||||||
@@ -121,3 +121,32 @@ IEnumerator Start()
|
|||||||
}
|
}
|
||||||
````
|
````
|
||||||
|
|
||||||
|
**FairyGUI加载方案**
|
||||||
|
|
||||||
|
注意:在FairyGUI的面板销毁的时候,将资源句柄列表释放,否则会造成资源泄漏。
|
||||||
|
|
||||||
|
````c#
|
||||||
|
// 资源句柄列表
|
||||||
|
private List<AssetOperationHandle> _handles = new List<AssetOperationHandle>(100);
|
||||||
|
|
||||||
|
// 加载方法
|
||||||
|
private object LoadFunc(string name, string extension, System.Type type, out DestroyMethod method)
|
||||||
|
{
|
||||||
|
method = DestroyMethod.None;
|
||||||
|
string location = $"FairyRes/{name}{extension}";
|
||||||
|
var handle = YooAssets.LoadAssetSync(location , type);
|
||||||
|
_handles.Add(handle);
|
||||||
|
return handle.AssetObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 释放资源句柄列表
|
||||||
|
private void ReleaseHandles()
|
||||||
|
{
|
||||||
|
foreach(var handle in _handles)
|
||||||
|
{
|
||||||
|
handle.Release();
|
||||||
|
}
|
||||||
|
_handles.Clear();
|
||||||
|
}
|
||||||
|
````
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user