Compare commits

...

15 Commits
1.0.0 ... 1.0.2

Author SHA1 Message Date
hevinci
fb743ada63 Update CHANGELOG.md 2022-04-07 19:26:19 +08:00
hevinci
a17e742218 Update package.json 2022-04-07 19:26:16 +08:00
hevinci
d6b54dd49c Update AssetBundleTools
StreamingAssets目录下增加了用于存放打包资源的总文件夹
2022-04-07 19:18:33 +08:00
hevinci
b7a20d4bdb Update AssetBundleTools
修复了资源分组在特殊情况下打包报错的问题
2022-04-07 19:15:24 +08:00
hevinci
28c22694ba Update AssetSystem
修复在资源加载完成回调内释放自身资源句柄时的异常报错。
2022-04-07 14:24:09 +08:00
hevinci
efd0789e09 Update document 2022-04-07 12:05:21 +08:00
hevinci
d8b1396641 Update CHANGELOG.md 2022-04-07 10:28:59 +08:00
hevinci
ef46b4365d Update LICENSE 2022-04-07 10:28:47 +08:00
hevinci
0d7c93ac55 Update EditorTools.cs
修复Assets目录下存在多个YooAsset同名文件夹时,工具窗口无法显示的问题。
修复通过Packages导入YooAsset,工具窗口无法显示的问题。
2022-04-07 10:17:42 +08:00
hevinci
25088918d3 Update README.md 2022-04-06 16:51:50 +08:00
hevinci
bed435794e Update document 2022-04-06 14:58:59 +08:00
hevinci
ca6b6899a5 Update package.json 2022-04-06 14:50:30 +08:00
hevinci
33a0f7023c Update README.md 2022-04-06 14:50:24 +08:00
hevinci
60509a4a22 Update document 2022-04-06 14:50:21 +08:00
hevinci
4b39af0543 Update document 2022-04-06 14:34:30 +08:00
20 changed files with 196 additions and 76 deletions

View File

@@ -2,5 +2,24 @@
All notable changes to this package will be documented in this file.
## [v1.0.0-preview] - 2022-04-05
## [1.0.2] - 2022-04-07
### Fixed
- 修复在资源加载完成回调内释放自身资源句柄时的异常报错。
- 修复了资源分组在特殊情况下打包报错的问题。
### Changed
- StreamingAssets目录下增加了用于存放打包资源的总文件夹
## [1.0.1] - 2022-04-07
### Fixed
- 修复Assets目录下存在多个YooAsset同名文件夹时工具窗口无法显示的问题。
- 修复通过Packages导入YooAsset工具窗口无法显示的问题。
## [1.0.0] - 2022-04-05
*Compatible with Unity 2019.4*

View File

@@ -17,6 +17,14 @@ namespace YooAsset.Editor
return $"{projectPath}/Bundles";
}
/// <summary>
/// 获取流文件夹路径
/// </summary>
public static string GetStreamingAssetsFolderPath()
{
return $"{Application.dataPath}/StreamingAssets/YooAssets/";
}
/// <summary>
/// 获取构建管线的输出目录
/// </summary>
@@ -30,8 +38,8 @@ namespace YooAsset.Editor
/// </summary>
public static void ClearStreamingAssetsFolder()
{
string streamingPath = Application.dataPath + "/StreamingAssets";
EditorTools.ClearFolder(streamingPath);
string streamingFolderPath = GetStreamingAssetsFolderPath();
EditorTools.ClearFolder(streamingFolderPath);
}
/// <summary>
@@ -40,17 +48,17 @@ namespace YooAsset.Editor
/// </summary>
public static void DeleteStreamingAssetsIgnoreFiles()
{
string streamingPath = Application.dataPath + "/StreamingAssets";
if (Directory.Exists(streamingPath))
string streamingFolderPath = GetStreamingAssetsFolderPath();
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)
{
FileInfo info = new FileInfo(file);
info.Delete();
}
files = Directory.GetFiles(streamingPath, "*.meta", SearchOption.AllDirectories);
files = Directory.GetFiles(streamingFolderPath, "*.meta", SearchOption.AllDirectories);
foreach (var item in files)
{
FileInfo info = new FileInfo(item);

View File

@@ -89,10 +89,7 @@ namespace YooAsset.Editor
/// </summary>
public string GetAppendExtension()
{
if (IsRawFile)
return $".{YooAssetSettingsData.Setting.RawFileVariant}";
else
return $".{YooAssetSettingsData.Setting.AssetBundleFileVariant}";
return System.IO.Path.GetExtension(BundleName);
}
/// <summary>

View File

@@ -94,7 +94,7 @@ namespace YooAsset.Editor
if (buildAssetInfo.BundleNameIsValid() == false)
{
string bundleName = defaultPackRule.GetBundleName(new PackRuleData(buildAssetInfo.AssetPath));
bundleName = AssetBundleCollector.RevisedBundleName(bundleName);
bundleName = AssetBundleCollector.RevisedBundleName(bundleName, false);
buildAssetInfo.SetBundleName(bundleName);
}
}

View File

@@ -38,7 +38,7 @@ namespace YooAsset.Editor
continue;
string sourcePath = $"{pipelineOutputDirectory}/{patchBundle.BundleName}";
string destPath = $"{Application.dataPath}/StreamingAssets/{patchBundle.Hash}";
string destPath = $"{AssetBundleBuilderHelper.GetStreamingAssetsFolderPath()}/{patchBundle.Hash}";
Debug.Log($"拷贝内置文件到流目录:{patchBundle.BundleName}");
EditorTools.CopyFile(sourcePath, destPath, true);
}
@@ -46,14 +46,14 @@ namespace YooAsset.Editor
// 拷贝清单文件
{
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);
}
// 拷贝清单哈希文件
{
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);
}

View File

@@ -71,7 +71,7 @@ namespace YooAsset.Editor
continue;
if (result.ContainsKey(assetPath) == false)
{
string bundleName = GetBundleName(grouper, assetPath);
string bundleName = GetBundleName(grouper, assetPath, isRawAsset);
List<string> assetTags = GetAssetTags(grouper);
var collectAssetInfo = new CollectAssetInfo(bundleName, assetPath, assetTags, isRawAsset, NotWriteToAssetList);
collectAssetInfo.DependAssets = GetAllDependencies(assetPath);
@@ -91,7 +91,7 @@ namespace YooAsset.Editor
if (isRawAsset && NotWriteToAssetList)
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);
var collectAssetInfo = new CollectAssetInfo(bundleName, assetPath, assetTags, isRawAsset, NotWriteToAssetList);
result.Add(assetPath, collectAssetInfo);
@@ -139,7 +139,7 @@ namespace YooAsset.Editor
IFilterRule filterRuleInstance = AssetBundleGrouperSettingData.GetFilterRuleInstance(FilterRuleName);
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)
@@ -147,14 +147,17 @@ namespace YooAsset.Editor
System.Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath);
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));
return RevisedBundleName(bundleName);
{
IPackRule packRuleInstance = AssetBundleGrouperSettingData.GetPackRuleInstance(PackRuleName);
string bundleName = packRuleInstance.GetBundleName(new PackRuleData(assetPath, CollectPath, grouper.GrouperName));
return RevisedBundleName(bundleName, isRawAsset);
}
}
private List<string> GetAssetTags(AssetBundleGrouper grouper)
{
@@ -183,9 +186,18 @@ namespace YooAsset.Editor
/// <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(); ;
}
}
}
}

View File

@@ -15,7 +15,7 @@ namespace YooAsset.Editor
/// </summary>
public static class EditorTools
{
#region Assembly
#region Assembly
/// <summary>
/// 调用私有的静态方法
/// </summary>
@@ -49,9 +49,9 @@ namespace YooAsset.Editor
}
return methodInfo.Invoke(null, parameters);
}
#endregion
#endregion
#region EditorUtility
#region EditorUtility
/// <summary>
/// 搜集资源
/// </summary>
@@ -156,9 +156,9 @@ namespace YooAsset.Editor
{
EditorUtility.ClearProgressBar();
}
#endregion
#endregion
#region EditorWindow
#region EditorWindow
public static void FocusUnitySceneWindow()
{
EditorWindow.FocusWindowIfItsOpen<SceneView>();
@@ -188,9 +188,9 @@ namespace YooAsset.Editor
System.Type T = Assembly.Load("UnityEditor").GetType("UnityEditor.ConsoleWindow");
EditorWindow.GetWindow(T, false, "Console", true);
}
#endregion
#endregion
#region
#region
private static MethodInfo _clearConsoleMethod;
private static MethodInfo ClearConsoleMethod
{
@@ -213,9 +213,9 @@ namespace YooAsset.Editor
{
ClearConsoleMethod.Invoke(new object(), null);
}
#endregion
#endregion
#region
#region
/// <summary>
/// 创建文件所在的目录
/// </summary>
@@ -409,9 +409,9 @@ namespace YooAsset.Editor
else
return Encoding.UTF8.GetString(bytes.ToArray());
}
#endregion
#endregion
#region
#region
private static string YooAssetPath;
/// <summary>
@@ -430,26 +430,40 @@ namespace YooAsset.Editor
if (string.IsNullOrEmpty(YooAssetPath) == false)
return YooAssetPath;
string packagesPath = ("Packages/com.tuyoo.yooasset/README.md");
// 从Pakcages目录下搜索
string packagesPath = ("Packages/com.tuyoogame.yooasset/README.md");
var obj = AssetDatabase.LoadAssetAtPath(packagesPath, typeof(TextAsset));
if(obj != null)
if (obj != null)
{
YooAssetPath = "Packages/com.tuyoo.yooasset/";
YooAssetPath = "Packages/com.tuyoogame.yooasset/";
return YooAssetPath;
}
// 从Assets目录下搜索
string[] allDirectorys = Directory.GetDirectories(Application.dataPath, "YooAsset", SearchOption.AllDirectories);
if (allDirectorys.Length == 0)
{
Debug.LogError("Not found YooAsset Folder!");
Debug.LogError("Not found YooAsset Package !");
return string.Empty;
}
if (allDirectorys.Length > 1)
string targetDirectory = string.Empty;
foreach (var directory in allDirectorys)
{
Debug.LogError("Found multiple YooAsset Folders!");
string asmdefFilePath = $"{directory}/Editor/YooAsset.Editor.asmdef";
if (File.Exists(asmdefFilePath))
{
targetDirectory = directory;
break;
}
}
if (string.IsNullOrEmpty(targetDirectory))
{
Debug.LogError("Should never get here !");
return string.Empty;
}
YooAssetPath = AbsolutePathToAssetPath(allDirectorys[0]);
YooAssetPath = AbsolutePathToAssetPath(targetDirectory);
return YooAssetPath;
}
@@ -504,9 +518,9 @@ namespace YooAsset.Editor
}
return string.Empty;
}
#endregion
#endregion
#region
#region
/// <summary>
/// 是否含有中文
/// </summary>
@@ -567,9 +581,9 @@ namespace YooAsset.Editor
else
return content.Substring(startIndex + key.Length);
}
#endregion
#endregion
#region
#region
// 枚举
public static void PlayerSetEnum<T>(string key, T value)
{
@@ -581,6 +595,6 @@ namespace YooAsset.Editor
string enumName = EditorPrefs.GetString(key, defaultValue.ToString());
return StringUtility.NameToEnum<T>(enumName);
}
#endregion
#endregion
}
}

View File

@@ -1,6 +1,6 @@
fileFormatVersion: 2
guid: 46c04934b6325ae4eaf66ae32034e329
DefaultImporter:
guid: 3fec07d458534d34ea14d1b1a0a5100b
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:

View File

@@ -11,10 +11,7 @@ namespace YooAsset
}
internal override void InvokeCallback()
{
if (IsValid)
{
_callback?.Invoke(this);
}
_callback?.Invoke(this);
}
/// <summary>

View File

@@ -11,10 +11,7 @@ namespace YooAsset
}
internal override void InvokeCallback()
{
if (IsValid)
{
_callback?.Invoke(this);
}
_callback?.Invoke(this);
}
/// <summary>

View File

@@ -10,10 +10,7 @@ namespace YooAsset
}
internal override void InvokeCallback()
{
if (IsValid)
{
_callback?.Invoke(this);
}
_callback?.Invoke(this);
}
/// <summary>

View File

@@ -224,9 +224,14 @@ namespace YooAsset
}
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();
}

View File

@@ -30,7 +30,7 @@ namespace YooAsset
/// </summary>
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>

View File

@@ -1,9 +1,8 @@
{
"name": "com.tuyoogame.yooasset",
"displayName": "YooAsset",
"version": "0.0.1-preview",
"version": "1.0.2",
"unity": "2019.4",
"keywords": [ "YooAsset", "Resources", "AssetBundle" ],
"description": "unity3d resources management system",
"author": {
"name": "TuYoo Games",
@@ -11,7 +10,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/tuyoogame/YooAsset"
"url": "https://github.com/tuyoogame/YooAsset.git"
},
"relatedPackages": {},
"dependencies": {}

View File

@@ -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();
}
````

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

View File

@@ -1,12 +1,51 @@
# 快速开始
**下载安装**
#### **下载安装**
1. 通过OpenUPM安装
2. 通过Packages安装
3. 通过GIT安装
1. **通过PackageManager安装**
**系统需求**
打开管理界面 **Edit/Project Settings/Package Manager**
````
// 输入以下内容
Name: package.openupm.cn
URL: https://package.openupm.cn
Scope(s): com.tuyoogame.yooasset
````
![image](https://github.com/tuyoogame/YooAsset/raw/main/Docs/Image/QuickStart-img1.jpg)
打开管理界面 **Edit/Windows/Package Manager**
![image](https://github.com/tuyoogame/YooAsset/raw/main/Docs/Image/QuickStart-img2.jpg)
2. **通过Packages清单安装**
直接修改Packages文件夹下的清单文件manifest.json
````json
{
"dependencies": {
"com.tuyoogame.yooasset": "0.0.1-preview",
......
},
"scopedRegistries": [
{
"name": "package.openupm.cn",
"url": "https://package.openupm.cn",
"scopes": [
"com.tuyoogame.yooasset"
]
}
]
}
````
3. **通过Github下载安装**
在发布的Release版本中选择最新版本下载Source Code压缩包。
#### **系统需求**
支持版本: Unity2019.4+
@@ -14,7 +53,7 @@
开发环境: .NET4.x
**目录结构**
#### **目录结构**
````
Assets

View File

@@ -1,7 +1,9 @@
[![License](https://img.shields.io/github/license/tuyoogame/YooAsset)](https://github.com/tuyoogame/YooAsset/blob/master/LICENSE)
![image](https://github.com/tuyoogame/YooAsset/raw/main/Docs/Image/LOGO.png)
# YooAsset
[![License](https://img.shields.io/github/license/tuyoogame/YooAsset)](https://github.com/tuyoogame/YooAsset/blob/master/LICENSE)[![openupm](https://img.shields.io/npm/v/com.tuyoogame.yooasset?label=openupm&registry_uri=https://package.openupm.com)](https://openupm.cn/packages/com.tuyoogame.yooasset/)
**YooAsset**是一套用于Unity3D的资源管理系统用于帮助研发团队快速部署和交付游戏。
它可以满足商业化游戏的各类需求并且经历多款百万DAU游戏产品的验证。
@@ -57,7 +59,12 @@
Coming soon...
### 社区
**QQ群963240451**
### 友情链接
[huatuo](https://github.com/focus-creative-games/huatuo):华佗是一个**特性完整、零成本、高性能、低内存**的近乎完美的c#热更新方案