mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-23 01:00:16 +00:00
Compare commits
19 Commits
1.5.2-prev
...
1.5.3-prev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e31799e78b | ||
|
|
a8405eea6d | ||
|
|
c11f072c50 | ||
|
|
b22bbd4e27 | ||
|
|
664866b627 | ||
|
|
ad9bdc6574 | ||
|
|
b93b993951 | ||
|
|
cb2cb4e556 | ||
|
|
ab32bd390d | ||
|
|
b34374adfa | ||
|
|
b53b6a4246 | ||
|
|
191fbff768 | ||
|
|
e8a4ddf331 | ||
|
|
aee6e2d2f8 | ||
|
|
b737b20602 | ||
|
|
b5df539392 | ||
|
|
36c53e5d94 | ||
|
|
15ce6b8c8c | ||
|
|
19aa82c131 |
@@ -2,6 +2,41 @@
|
|||||||
|
|
||||||
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.5.3-preview] - 2023-07-28
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- 修复了Unity2020以下版本的编辑器提示找不到"autoLoadAssetBundle"的编译错误。
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- 新增了支持开发者分发资源的功能。
|
||||||
|
|
||||||
|
```c#
|
||||||
|
public interface IQueryServices
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 查询应用程序里的内置资源是否存在
|
||||||
|
/// </summary>
|
||||||
|
bool QueryStreamingAssets(string packageName, string fileName);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询是否为开发者分发的资源
|
||||||
|
/// </summary>
|
||||||
|
bool QueryDeliveryFiles(string packageName, string fileName);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取开发者分发的资源信息
|
||||||
|
/// </summary>
|
||||||
|
DeliveryFileInfo GetDeliveryFileInfo(string packageName, string fileName);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- 针对资源清单更新方法传入参数的合法性检测。
|
||||||
|
- 编辑器下针对激活的资源清单有效性的检测。
|
||||||
|
|
||||||
## [1.5.2-preview] - 2023-07-18
|
## [1.5.2-preview] - 2023-07-18
|
||||||
|
|
||||||
重新设计了对WebGL平台的支持,新增加了专属模式:WebPlayMode
|
重新设计了对WebGL平台的支持,新增加了专属模式:WebPlayMode
|
||||||
|
|||||||
@@ -1,215 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.IO;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEditor;
|
|
||||||
using UnityEditor.Animations;
|
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
|
||||||
{
|
|
||||||
public static class AssetBundleBuilderTools
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 检测所有损坏的预制体文件
|
|
||||||
/// </summary>
|
|
||||||
public static void CheckCorruptionPrefab(List<string> searchDirectorys)
|
|
||||||
{
|
|
||||||
if (searchDirectorys.Count == 0)
|
|
||||||
throw new Exception("路径列表不能为空!");
|
|
||||||
|
|
||||||
// 获取所有资源列表
|
|
||||||
int checkCount = 0;
|
|
||||||
int invalidCount = 0;
|
|
||||||
string[] findAssets = EditorTools.FindAssets(EAssetSearchType.Prefab, searchDirectorys.ToArray());
|
|
||||||
foreach (string assetPath in findAssets)
|
|
||||||
{
|
|
||||||
UnityEngine.Object prefab = AssetDatabase.LoadAssetAtPath(assetPath, typeof(UnityEngine.Object));
|
|
||||||
if (prefab == null)
|
|
||||||
{
|
|
||||||
invalidCount++;
|
|
||||||
Debug.LogError($"发现损坏预制件:{assetPath}");
|
|
||||||
}
|
|
||||||
EditorTools.DisplayProgressBar("检测预制件文件是否损坏", ++checkCount, findAssets.Length);
|
|
||||||
}
|
|
||||||
EditorTools.ClearProgressBar();
|
|
||||||
|
|
||||||
if (invalidCount == 0)
|
|
||||||
Debug.Log($"没有发现损坏预制件");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 检测所有动画控制器的冗余状态
|
|
||||||
/// </summary>
|
|
||||||
public static void FindRedundantAnimationState(List<string> searchDirectorys)
|
|
||||||
{
|
|
||||||
if (searchDirectorys.Count == 0)
|
|
||||||
throw new Exception("路径列表不能为空!");
|
|
||||||
|
|
||||||
// 获取所有资源列表
|
|
||||||
int checkCount = 0;
|
|
||||||
int findCount = 0;
|
|
||||||
string[] findAssets = EditorTools.FindAssets(EAssetSearchType.RuntimeAnimatorController, searchDirectorys.ToArray());
|
|
||||||
foreach (string assetPath in findAssets)
|
|
||||||
{
|
|
||||||
AnimatorController animator= AssetDatabase.LoadAssetAtPath<AnimatorController>(assetPath);
|
|
||||||
if (FindRedundantAnimationState(animator))
|
|
||||||
{
|
|
||||||
findCount++;
|
|
||||||
Debug.LogWarning($"发现冗余的动画控制器:{assetPath}");
|
|
||||||
}
|
|
||||||
EditorTools.DisplayProgressBar("检测冗余的动画控制器", ++checkCount, findAssets.Length);
|
|
||||||
}
|
|
||||||
EditorTools.ClearProgressBar();
|
|
||||||
|
|
||||||
if (findCount == 0)
|
|
||||||
Debug.Log($"没有发现冗余的动画控制器");
|
|
||||||
else
|
|
||||||
AssetDatabase.SaveAssets();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 清理所有材质球的冗余属性
|
|
||||||
/// </summary>
|
|
||||||
public static void ClearMaterialUnusedProperty(List<string> searchDirectorys)
|
|
||||||
{
|
|
||||||
if (searchDirectorys.Count == 0)
|
|
||||||
throw new Exception("路径列表不能为空!");
|
|
||||||
|
|
||||||
// 获取所有资源列表
|
|
||||||
int checkCount = 0;
|
|
||||||
int removedCount = 0;
|
|
||||||
string[] findAssets = EditorTools.FindAssets(EAssetSearchType.Material, searchDirectorys.ToArray());
|
|
||||||
foreach (string assetPath in findAssets)
|
|
||||||
{
|
|
||||||
Material mat = AssetDatabase.LoadAssetAtPath<Material>(assetPath);
|
|
||||||
if (ClearMaterialUnusedProperty(mat))
|
|
||||||
{
|
|
||||||
removedCount++;
|
|
||||||
Debug.LogWarning($"材质球已被处理:{assetPath}");
|
|
||||||
}
|
|
||||||
EditorTools.DisplayProgressBar("清理冗余的材质球", ++checkCount, findAssets.Length);
|
|
||||||
}
|
|
||||||
EditorTools.ClearProgressBar();
|
|
||||||
|
|
||||||
if (removedCount == 0)
|
|
||||||
Debug.Log($"没有发现冗余的材质球");
|
|
||||||
else
|
|
||||||
AssetDatabase.SaveAssets();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 清理无用的材质球属性
|
|
||||||
/// </summary>
|
|
||||||
private static bool ClearMaterialUnusedProperty(Material mat)
|
|
||||||
{
|
|
||||||
bool removeUnused = false;
|
|
||||||
SerializedObject so = new SerializedObject(mat);
|
|
||||||
SerializedProperty sp = so.FindProperty("m_SavedProperties");
|
|
||||||
|
|
||||||
sp.Next(true);
|
|
||||||
do
|
|
||||||
{
|
|
||||||
if (sp.isArray == false)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
for (int i = sp.arraySize - 1; i >= 0; --i)
|
|
||||||
{
|
|
||||||
var p1 = sp.GetArrayElementAtIndex(i);
|
|
||||||
if (p1.isArray)
|
|
||||||
{
|
|
||||||
for (int ii = p1.arraySize - 1; ii >= 0; --ii)
|
|
||||||
{
|
|
||||||
var p2 = p1.GetArrayElementAtIndex(ii);
|
|
||||||
var val = p2.FindPropertyRelative("first");
|
|
||||||
if (mat.HasProperty(val.stringValue) == false)
|
|
||||||
{
|
|
||||||
Debug.Log($"Material {mat.name} remove unused property : {val.stringValue}");
|
|
||||||
p1.DeleteArrayElementAtIndex(ii);
|
|
||||||
removeUnused = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var val = p1.FindPropertyRelative("first");
|
|
||||||
if (mat.HasProperty(val.stringValue) == false)
|
|
||||||
{
|
|
||||||
Debug.Log($"Material {mat.name} remove unused property : {val.stringValue}");
|
|
||||||
sp.DeleteArrayElementAtIndex(i);
|
|
||||||
removeUnused = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
while (sp.Next(false));
|
|
||||||
so.ApplyModifiedProperties();
|
|
||||||
return removeUnused;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 查找动画控制器里冗余的动画状态机
|
|
||||||
/// </summary>
|
|
||||||
private static bool FindRedundantAnimationState(AnimatorController animatorController)
|
|
||||||
{
|
|
||||||
if (animatorController == null)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
string assetPath = AssetDatabase.GetAssetPath(animatorController);
|
|
||||||
|
|
||||||
// 查找使用的状态机名称
|
|
||||||
List<string> usedStateNames = new List<string>();
|
|
||||||
foreach (var layer in animatorController.layers)
|
|
||||||
{
|
|
||||||
foreach (var state in layer.stateMachine.states)
|
|
||||||
{
|
|
||||||
usedStateNames.Add(state.state.name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
List<string> allLines = new List<string>();
|
|
||||||
List<int> stateIndexList = new List<int>();
|
|
||||||
using (StreamReader reader = File.OpenText(assetPath))
|
|
||||||
{
|
|
||||||
string content;
|
|
||||||
while (null != (content = reader.ReadLine()))
|
|
||||||
{
|
|
||||||
allLines.Add(content);
|
|
||||||
if (content.StartsWith("AnimatorState:"))
|
|
||||||
{
|
|
||||||
stateIndexList.Add(allLines.Count - 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
List<string> allStateNames = new List<string>();
|
|
||||||
foreach (var index in stateIndexList)
|
|
||||||
{
|
|
||||||
for (int i = index; i < allLines.Count; i++)
|
|
||||||
{
|
|
||||||
string content = allLines[i];
|
|
||||||
content = content.Trim();
|
|
||||||
if (content.StartsWith("m_Name"))
|
|
||||||
{
|
|
||||||
string[] splits = content.Split(':');
|
|
||||||
string name = splits[1].TrimStart(' '); //移除前面的空格
|
|
||||||
allStateNames.Add(name);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool foundRedundantState = false;
|
|
||||||
foreach (var stateName in allStateNames)
|
|
||||||
{
|
|
||||||
if (usedStateNames.Contains(stateName) == false)
|
|
||||||
{
|
|
||||||
Debug.LogWarning($"发现冗余的动画文件:{assetPath}={stateName}");
|
|
||||||
foundRedundantState = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return foundRedundantState;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: fe50795c51a46884088139b840c1557f
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: d6268d725eec21b4aae819adc1553f0e
|
|
||||||
folderAsset: yes
|
|
||||||
DefaultImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -128,11 +128,13 @@ namespace YooAsset
|
|||||||
#else
|
#else
|
||||||
foreach (var provider in _providerList)
|
foreach (var provider in _providerList)
|
||||||
{
|
{
|
||||||
provider.DestroySafely();
|
provider.WaitForAsyncComplete();
|
||||||
|
provider.Destroy();
|
||||||
}
|
}
|
||||||
foreach (var loader in _loaderList)
|
foreach (var loader in _loaderList)
|
||||||
{
|
{
|
||||||
loader.DestroySafely();
|
loader.WaitForAsyncComplete();
|
||||||
|
loader.Destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
_providerList.Clear();
|
_providerList.Clear();
|
||||||
@@ -416,7 +418,7 @@ namespace YooAsset
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region 调试信息
|
#region 调试信息
|
||||||
internal List<DebugProviderInfo> GetDebugReportInfos()
|
internal List<DebugProviderInfo> GetDebugReportInfos()
|
||||||
{
|
{
|
||||||
List<DebugProviderInfo> result = new List<DebugProviderInfo>(_providerList.Count);
|
List<DebugProviderInfo> result = new List<DebugProviderInfo>(_providerList.Count);
|
||||||
@@ -444,6 +446,6 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -15,7 +15,8 @@ namespace YooAsset
|
|||||||
CheckDownload,
|
CheckDownload,
|
||||||
Unpack,
|
Unpack,
|
||||||
CheckUnpack,
|
CheckUnpack,
|
||||||
LoadFile,
|
LoadBundleFile,
|
||||||
|
LoadDeliveryFile,
|
||||||
CheckLoadFile,
|
CheckLoadFile,
|
||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
@@ -59,19 +60,24 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_steps = ESteps.LoadFile;
|
_steps = ESteps.LoadBundleFile;
|
||||||
FileLoadPath = MainBundleInfo.Bundle.StreamingFilePath;
|
FileLoadPath = MainBundleInfo.Bundle.StreamingFilePath;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
_steps = ESteps.LoadFile;
|
_steps = ESteps.LoadBundleFile;
|
||||||
FileLoadPath = MainBundleInfo.Bundle.StreamingFilePath;
|
FileLoadPath = MainBundleInfo.Bundle.StreamingFilePath;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else if (MainBundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromCache)
|
else if (MainBundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromCache)
|
||||||
{
|
{
|
||||||
_steps = ESteps.LoadFile;
|
_steps = ESteps.LoadBundleFile;
|
||||||
FileLoadPath = MainBundleInfo.Bundle.CachedDataFilePath;
|
FileLoadPath = MainBundleInfo.Bundle.CachedDataFilePath;
|
||||||
}
|
}
|
||||||
|
else if (MainBundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromDelivery)
|
||||||
|
{
|
||||||
|
_steps = ESteps.LoadDeliveryFile;
|
||||||
|
FileLoadPath = MainBundleInfo.DeliveryFilePath;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new System.NotImplementedException(MainBundleInfo.LoadMode.ToString());
|
throw new System.NotImplementedException(MainBundleInfo.LoadMode.ToString());
|
||||||
@@ -103,7 +109,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_steps = ESteps.LoadFile;
|
_steps = ESteps.LoadBundleFile;
|
||||||
return; //下载完毕等待一帧再去加载!
|
return; //下载完毕等待一帧再去加载!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -134,12 +140,12 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_steps = ESteps.LoadFile;
|
_steps = ESteps.LoadBundleFile;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5. 加载AssetBundle
|
// 5. 加载AssetBundle
|
||||||
if (_steps == ESteps.LoadFile)
|
if (_steps == ESteps.LoadBundleFile)
|
||||||
{
|
{
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
// 注意:Unity2017.4编辑器模式下,如果AssetBundle文件不存在会导致编辑器崩溃,这里做了预判。
|
// 注意:Unity2017.4编辑器模式下,如果AssetBundle文件不存在会导致编辑器崩溃,这里做了预判。
|
||||||
@@ -214,7 +220,35 @@ namespace YooAsset
|
|||||||
_steps = ESteps.CheckLoadFile;
|
_steps = ESteps.CheckLoadFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 6. 检测AssetBundle加载结果
|
// 6. 加载AssetBundle
|
||||||
|
if (_steps == ESteps.LoadDeliveryFile)
|
||||||
|
{
|
||||||
|
// 设置下载进度
|
||||||
|
DownloadProgress = 1f;
|
||||||
|
DownloadedBytes = (ulong)MainBundleInfo.Bundle.FileSize;
|
||||||
|
|
||||||
|
// Load assetBundle file
|
||||||
|
var loadMethod = (EBundleLoadMethod)MainBundleInfo.Bundle.LoadMethod;
|
||||||
|
if (loadMethod == EBundleLoadMethod.Normal)
|
||||||
|
{
|
||||||
|
ulong offset = MainBundleInfo.DeliveryFileOffset;
|
||||||
|
if (_isWaitForAsyncComplete)
|
||||||
|
CacheBundle = AssetBundle.LoadFromFile(FileLoadPath, 0, offset);
|
||||||
|
else
|
||||||
|
_createRequest = AssetBundle.LoadFromFileAsync(FileLoadPath, 0, offset);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EStatus.Failed;
|
||||||
|
LastError = $"Delivery file not support encryption : {MainBundleInfo.Bundle.BundleName}";
|
||||||
|
YooLogger.Error(LastError);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_steps = ESteps.CheckLoadFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 7. 检测AssetBundle加载结果
|
||||||
if (_steps == ESteps.CheckLoadFile)
|
if (_steps == ESteps.CheckLoadFile)
|
||||||
{
|
{
|
||||||
if (_createRequest != null)
|
if (_createRequest != null)
|
||||||
|
|||||||
@@ -144,15 +144,6 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 销毁资源包(安全模式)
|
|
||||||
/// </summary>
|
|
||||||
public void DestroySafely()
|
|
||||||
{
|
|
||||||
WaitForAsyncComplete();
|
|
||||||
Destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 轮询更新
|
/// 轮询更新
|
||||||
|
|||||||
@@ -54,6 +54,11 @@ namespace YooAsset
|
|||||||
_steps = ESteps.CheckFile;
|
_steps = ESteps.CheckFile;
|
||||||
FileLoadPath = MainBundleInfo.Bundle.CachedDataFilePath;
|
FileLoadPath = MainBundleInfo.Bundle.CachedDataFilePath;
|
||||||
}
|
}
|
||||||
|
else if (MainBundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromDelivery)
|
||||||
|
{
|
||||||
|
_steps = ESteps.CheckFile;
|
||||||
|
FileLoadPath = MainBundleInfo.DeliveryFilePath;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new System.NotImplementedException(MainBundleInfo.LoadMode.ToString());
|
throw new System.NotImplementedException(MainBundleInfo.LoadMode.ToString());
|
||||||
|
|||||||
@@ -140,22 +140,6 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 销毁资源对象(安全模式)
|
|
||||||
/// </summary>
|
|
||||||
public void DestroySafely()
|
|
||||||
{
|
|
||||||
if (Status == EStatus.Loading || Status == EStatus.Checking)
|
|
||||||
{
|
|
||||||
WaitForAsyncComplete();
|
|
||||||
Destroy();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Destroy();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否可以销毁
|
/// 是否可以销毁
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -72,14 +72,18 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
uint crc = _bundleInfo.Bundle.UnityCRC;
|
uint crc = _bundleInfo.Bundle.UnityCRC;
|
||||||
_downloadhandler = new DownloadHandlerAssetBundle(_requestURL, crc);
|
_downloadhandler = new DownloadHandlerAssetBundle(_requestURL, crc);
|
||||||
|
#if UNITY_2020_3_OR_NEWER
|
||||||
_downloadhandler.autoLoadAssetBundle = false;
|
_downloadhandler.autoLoadAssetBundle = false;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
uint crc = _bundleInfo.Bundle.UnityCRC;
|
uint crc = _bundleInfo.Bundle.UnityCRC;
|
||||||
var hash = Hash128.Parse(_bundleInfo.Bundle.FileHash);
|
var hash = Hash128.Parse(_bundleInfo.Bundle.FileHash);
|
||||||
_downloadhandler = new DownloadHandlerAssetBundle(_requestURL, hash, crc);
|
_downloadhandler = new DownloadHandlerAssetBundle(_requestURL, hash, crc);
|
||||||
|
#if UNITY_2020_3_OR_NEWER
|
||||||
_downloadhandler.autoLoadAssetBundle = false;
|
_downloadhandler.autoLoadAssetBundle = false;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
_webRequest.downloadHandler = _downloadhandler;
|
_webRequest.downloadHandler = _downloadhandler;
|
||||||
@@ -169,7 +173,7 @@ namespace YooAsset
|
|||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
_lastError = "user abort";
|
_lastError = "user abort";
|
||||||
_lastCode = 0;
|
_lastCode = 0;
|
||||||
|
|
||||||
DisposeRequest();
|
DisposeRequest();
|
||||||
DisposeHandler();
|
DisposeHandler();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ namespace YooAsset
|
|||||||
public enum ELoadMode
|
public enum ELoadMode
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
|
LoadFromDelivery,
|
||||||
LoadFromStreaming,
|
LoadFromStreaming,
|
||||||
LoadFromCache,
|
LoadFromCache,
|
||||||
LoadFromRemote,
|
LoadFromRemote,
|
||||||
@@ -25,6 +26,16 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string RemoteFallbackURL { private set; get; }
|
public string RemoteFallbackURL { private set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 开发者分发的文件地址
|
||||||
|
/// </summary>
|
||||||
|
public string DeliveryFilePath { private set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 开发者分发的文件偏移量
|
||||||
|
/// </summary>
|
||||||
|
public ulong DeliveryFileOffset { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 注意:该字段只用于帮助编辑器下的模拟模式。
|
/// 注意:该字段只用于帮助编辑器下的模拟模式。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -40,6 +51,17 @@ namespace YooAsset
|
|||||||
LoadMode = loadMode;
|
LoadMode = loadMode;
|
||||||
RemoteMainURL = mainURL;
|
RemoteMainURL = mainURL;
|
||||||
RemoteFallbackURL = fallbackURL;
|
RemoteFallbackURL = fallbackURL;
|
||||||
|
DeliveryFilePath = string.Empty;
|
||||||
|
DeliveryFileOffset = 0;
|
||||||
|
}
|
||||||
|
public BundleInfo(PackageBundle bundle, ELoadMode loadMode, string deliveryFilePath, ulong deliveryFileOffset)
|
||||||
|
{
|
||||||
|
Bundle = bundle;
|
||||||
|
LoadMode = loadMode;
|
||||||
|
RemoteMainURL = string.Empty;
|
||||||
|
RemoteFallbackURL = string.Empty;
|
||||||
|
DeliveryFilePath = deliveryFilePath;
|
||||||
|
DeliveryFileOffset = deliveryFileOffset;
|
||||||
}
|
}
|
||||||
public BundleInfo(PackageBundle bundle, ELoadMode loadMode)
|
public BundleInfo(PackageBundle bundle, ELoadMode loadMode)
|
||||||
{
|
{
|
||||||
@@ -47,6 +69,8 @@ namespace YooAsset
|
|||||||
LoadMode = loadMode;
|
LoadMode = loadMode;
|
||||||
RemoteMainURL = string.Empty;
|
RemoteMainURL = string.Empty;
|
||||||
RemoteFallbackURL = string.Empty;
|
RemoteFallbackURL = string.Empty;
|
||||||
|
DeliveryFilePath = string.Empty;
|
||||||
|
DeliveryFileOffset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ namespace YooAsset
|
|||||||
string savePath = PersistentTools.GetPersistent(_packageName).GetSandboxPackageManifestFilePath(_packageVersion);
|
string savePath = PersistentTools.GetPersistent(_packageName).GetSandboxPackageManifestFilePath(_packageVersion);
|
||||||
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(_packageName, _packageVersion);
|
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(_packageName, _packageVersion);
|
||||||
string webURL = GetDownloadRequestURL(fileName);
|
string webURL = GetDownloadRequestURL(fileName);
|
||||||
YooLogger.Log($"Beginning to download manifest file : {webURL}");
|
YooLogger.Log($"Beginning to download package manifest file : {webURL}");
|
||||||
_downloader2 = new UnityWebFileRequester();
|
_downloader2 = new UnityWebFileRequester();
|
||||||
_downloader2.SendRequest(webURL, savePath, _timeout);
|
_downloader2.SendRequest(webURL, savePath, _timeout);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ namespace YooAsset
|
|||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
|
CheckParams,
|
||||||
CheckActiveManifest,
|
CheckActiveManifest,
|
||||||
TryLoadCacheManifest,
|
TryLoadCacheManifest,
|
||||||
DownloadManifest,
|
DownloadManifest,
|
||||||
@@ -87,13 +88,34 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
internal override void Start()
|
internal override void Start()
|
||||||
{
|
{
|
||||||
_steps = ESteps.CheckActiveManifest;
|
_steps = ESteps.CheckParams;
|
||||||
}
|
}
|
||||||
internal override void Update()
|
internal override void Update()
|
||||||
{
|
{
|
||||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (_steps == ESteps.CheckParams)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(_packageName))
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = "Package name is null or empty.";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(_packageVersion))
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = "Package version is null or empty.";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_steps = ESteps.CheckActiveManifest;
|
||||||
|
}
|
||||||
|
|
||||||
if (_steps == ESteps.CheckActiveManifest)
|
if (_steps == ESteps.CheckActiveManifest)
|
||||||
{
|
{
|
||||||
// 检测当前激活的清单对象
|
// 检测当前激活的清单对象
|
||||||
@@ -198,6 +220,7 @@ namespace YooAsset
|
|||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
|
CheckParams,
|
||||||
CheckActiveManifest,
|
CheckActiveManifest,
|
||||||
LoadRemoteManifest,
|
LoadRemoteManifest,
|
||||||
Done,
|
Done,
|
||||||
@@ -220,13 +243,34 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
internal override void Start()
|
internal override void Start()
|
||||||
{
|
{
|
||||||
_steps = ESteps.CheckActiveManifest;
|
_steps = ESteps.CheckParams;
|
||||||
}
|
}
|
||||||
internal override void Update()
|
internal override void Update()
|
||||||
{
|
{
|
||||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (_steps == ESteps.CheckParams)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(_packageName))
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = "Package name is null or empty.";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(_packageVersion))
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = "Package version is null or empty.";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_steps = ESteps.CheckActiveManifest;
|
||||||
|
}
|
||||||
|
|
||||||
if (_steps == ESteps.CheckActiveManifest)
|
if (_steps == ESteps.CheckActiveManifest)
|
||||||
{
|
{
|
||||||
// 检测当前激活的清单对象
|
// 检测当前激活的清单对象
|
||||||
|
|||||||
@@ -51,6 +51,24 @@ namespace YooAsset
|
|||||||
return bundleInfo;
|
return bundleInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 查询相关
|
||||||
|
private bool IsBuildinPackageBundle(PackageBundle packageBundle)
|
||||||
|
{
|
||||||
|
return _queryServices.QueryStreamingAssets(_packageName, packageBundle.FileName);
|
||||||
|
}
|
||||||
|
private bool IsCachedPackageBundle(PackageBundle packageBundle)
|
||||||
|
{
|
||||||
|
return CacheSystem.IsCached(packageBundle.PackageName, packageBundle.CacheGUID);
|
||||||
|
}
|
||||||
|
private bool IsDeliveryPackageBundle(PackageBundle packageBundle)
|
||||||
|
{
|
||||||
|
return _queryServices.QueryDeliveryFiles(_packageName, packageBundle.FileName);
|
||||||
|
}
|
||||||
|
private DeliveryFileInfo GetDeiveryFileInfo(PackageBundle packageBundle)
|
||||||
|
{
|
||||||
|
return _queryServices.GetDeliveryFileInfo(_packageName, packageBundle.FileName);
|
||||||
|
}
|
||||||
|
|
||||||
#region IPlayModeServices接口
|
#region IPlayModeServices接口
|
||||||
public PackageManifest ActiveManifest
|
public PackageManifest ActiveManifest
|
||||||
{
|
{
|
||||||
@@ -71,15 +89,6 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsBuildinPackageBundle(PackageBundle packageBundle)
|
|
||||||
{
|
|
||||||
return _queryServices.QueryStreamingAssets(_packageName, packageBundle.FileName);
|
|
||||||
}
|
|
||||||
private bool IsCachedPackageBundle(PackageBundle packageBundle)
|
|
||||||
{
|
|
||||||
return CacheSystem.IsCached(packageBundle.PackageName, packageBundle.CacheGUID);
|
|
||||||
}
|
|
||||||
|
|
||||||
UpdatePackageVersionOperation IPlayModeServices.UpdatePackageVersionAsync(bool appendTimeTicks, int timeout)
|
UpdatePackageVersionOperation IPlayModeServices.UpdatePackageVersionAsync(bool appendTimeTicks, int timeout)
|
||||||
{
|
{
|
||||||
var operation = new HostPlayModeUpdatePackageVersionOperation(this, _packageName, appendTimeTicks, timeout);
|
var operation = new HostPlayModeUpdatePackageVersionOperation(this, _packageName, appendTimeTicks, timeout);
|
||||||
@@ -110,6 +119,10 @@ namespace YooAsset
|
|||||||
List<PackageBundle> downloadList = new List<PackageBundle>(1000);
|
List<PackageBundle> downloadList = new List<PackageBundle>(1000);
|
||||||
foreach (var packageBundle in manifest.BundleList)
|
foreach (var packageBundle in manifest.BundleList)
|
||||||
{
|
{
|
||||||
|
// 忽略分发文件
|
||||||
|
if (IsDeliveryPackageBundle(packageBundle))
|
||||||
|
continue;
|
||||||
|
|
||||||
// 忽略缓存文件
|
// 忽略缓存文件
|
||||||
if (IsCachedPackageBundle(packageBundle))
|
if (IsCachedPackageBundle(packageBundle))
|
||||||
continue;
|
continue;
|
||||||
@@ -135,6 +148,10 @@ namespace YooAsset
|
|||||||
List<PackageBundle> downloadList = new List<PackageBundle>(1000);
|
List<PackageBundle> downloadList = new List<PackageBundle>(1000);
|
||||||
foreach (var packageBundle in manifest.BundleList)
|
foreach (var packageBundle in manifest.BundleList)
|
||||||
{
|
{
|
||||||
|
// 忽略分发文件
|
||||||
|
if (IsDeliveryPackageBundle(packageBundle))
|
||||||
|
continue;
|
||||||
|
|
||||||
// 忽略缓存文件
|
// 忽略缓存文件
|
||||||
if (IsCachedPackageBundle(packageBundle))
|
if (IsCachedPackageBundle(packageBundle))
|
||||||
continue;
|
continue;
|
||||||
@@ -196,6 +213,10 @@ namespace YooAsset
|
|||||||
List<PackageBundle> downloadList = new List<PackageBundle>(1000);
|
List<PackageBundle> downloadList = new List<PackageBundle>(1000);
|
||||||
foreach (var packageBundle in checkList)
|
foreach (var packageBundle in checkList)
|
||||||
{
|
{
|
||||||
|
// 忽略分发文件
|
||||||
|
if (IsDeliveryPackageBundle(packageBundle))
|
||||||
|
continue;
|
||||||
|
|
||||||
// 忽略缓存文件
|
// 忽略缓存文件
|
||||||
if (IsCachedPackageBundle(packageBundle))
|
if (IsCachedPackageBundle(packageBundle))
|
||||||
continue;
|
continue;
|
||||||
@@ -269,6 +290,14 @@ namespace YooAsset
|
|||||||
if (packageBundle == null)
|
if (packageBundle == null)
|
||||||
throw new Exception("Should never get here !");
|
throw new Exception("Should never get here !");
|
||||||
|
|
||||||
|
// 查询分发资源
|
||||||
|
if (IsDeliveryPackageBundle(packageBundle))
|
||||||
|
{
|
||||||
|
DeliveryFileInfo deliveryFileInfo = GetDeiveryFileInfo(packageBundle);
|
||||||
|
BundleInfo bundleInfo = new BundleInfo(packageBundle, BundleInfo.ELoadMode.LoadFromDelivery, deliveryFileInfo.DeliveryFilePath, deliveryFileInfo.DeliveryFileOffset);
|
||||||
|
return bundleInfo;
|
||||||
|
}
|
||||||
|
|
||||||
// 查询沙盒资源
|
// 查询沙盒资源
|
||||||
if (IsCachedPackageBundle(packageBundle))
|
if (IsCachedPackageBundle(packageBundle))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -18,6 +18,12 @@ namespace YooAsset
|
|||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 查询相关
|
||||||
|
private bool IsCachedPackageBundle(PackageBundle packageBundle)
|
||||||
|
{
|
||||||
|
return CacheSystem.IsCached(packageBundle.PackageName, packageBundle.CacheGUID);
|
||||||
|
}
|
||||||
|
|
||||||
#region IPlayModeServices接口
|
#region IPlayModeServices接口
|
||||||
public PackageManifest ActiveManifest
|
public PackageManifest ActiveManifest
|
||||||
{
|
{
|
||||||
@@ -34,11 +40,6 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsCachedPackageBundle(PackageBundle packageBundle)
|
|
||||||
{
|
|
||||||
return CacheSystem.IsCached(packageBundle.PackageName, packageBundle.CacheGUID);
|
|
||||||
}
|
|
||||||
|
|
||||||
UpdatePackageVersionOperation IPlayModeServices.UpdatePackageVersionAsync(bool appendTimeTicks, int timeout)
|
UpdatePackageVersionOperation IPlayModeServices.UpdatePackageVersionAsync(bool appendTimeTicks, int timeout)
|
||||||
{
|
{
|
||||||
var operation = new OfflinePlayModeUpdatePackageVersionOperation();
|
var operation = new OfflinePlayModeUpdatePackageVersionOperation();
|
||||||
|
|||||||
@@ -41,6 +41,12 @@ namespace YooAsset
|
|||||||
return bundleInfo;
|
return bundleInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 查询相关
|
||||||
|
private bool IsBuildinPackageBundle(PackageBundle packageBundle)
|
||||||
|
{
|
||||||
|
return _queryServices.QueryStreamingAssets(_packageName, packageBundle.FileName);
|
||||||
|
}
|
||||||
|
|
||||||
#region IPlayModeServices接口
|
#region IPlayModeServices接口
|
||||||
public PackageManifest ActiveManifest
|
public PackageManifest ActiveManifest
|
||||||
{
|
{
|
||||||
@@ -57,11 +63,6 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsBuildinPackageBundle(PackageBundle packageBundle)
|
|
||||||
{
|
|
||||||
return _queryServices.QueryStreamingAssets(_packageName, packageBundle.FileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
UpdatePackageVersionOperation IPlayModeServices.UpdatePackageVersionAsync(bool appendTimeTicks, int timeout)
|
UpdatePackageVersionOperation IPlayModeServices.UpdatePackageVersionAsync(bool appendTimeTicks, int timeout)
|
||||||
{
|
{
|
||||||
var operation = new WebPlayModeUpdatePackageVersionOperation(this, _packageName, appendTimeTicks, timeout);
|
var operation = new WebPlayModeUpdatePackageVersionOperation(this, _packageName, appendTimeTicks, timeout);
|
||||||
|
|||||||
@@ -205,11 +205,19 @@ namespace YooAsset
|
|||||||
else
|
else
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
|
|
||||||
// 检测运行平台
|
// 检测运行时平台
|
||||||
if (_playMode == EPlayMode.HostPlayMode || _playMode == EPlayMode.OfflinePlayMode)
|
if (_playMode != EPlayMode.EditorSimulateMode)
|
||||||
{
|
{
|
||||||
#if UNITY_WEBGL
|
#if UNITY_WEBGL
|
||||||
throw new Exception($"WebGL plateform not support : {_playMode} ! Please use {nameof(EPlayMode.WebPlayMode)}");
|
if (_playMode != EPlayMode.WebPlayMode)
|
||||||
|
{
|
||||||
|
throw new Exception($"{_playMode} can not support WebGL plateform ! Please use {nameof(EPlayMode.WebPlayMode)}");
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
if (_playMode == EPlayMode.WebPlayMode)
|
||||||
|
{
|
||||||
|
throw new Exception($"{nameof(EPlayMode.WebPlayMode)} only support WebGL plateform !");
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -238,7 +246,7 @@ namespace YooAsset
|
|||||||
/// <param name="timeout">超时时间(默认值:60秒)</param>
|
/// <param name="timeout">超时时间(默认值:60秒)</param>
|
||||||
public UpdatePackageVersionOperation UpdatePackageVersionAsync(bool appendTimeTicks = true, int timeout = 60)
|
public UpdatePackageVersionOperation UpdatePackageVersionAsync(bool appendTimeTicks = true, int timeout = 60)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize(false);
|
||||||
return _playModeServices.UpdatePackageVersionAsync(appendTimeTicks, timeout);
|
return _playModeServices.UpdatePackageVersionAsync(appendTimeTicks, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -250,7 +258,7 @@ namespace YooAsset
|
|||||||
/// <param name="timeout">超时时间(默认值:60秒)</param>
|
/// <param name="timeout">超时时间(默认值:60秒)</param>
|
||||||
public UpdatePackageManifestOperation UpdatePackageManifestAsync(string packageVersion, bool autoSaveVersion = true, int timeout = 60)
|
public UpdatePackageManifestOperation UpdatePackageManifestAsync(string packageVersion, bool autoSaveVersion = true, int timeout = 60)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize(false);
|
||||||
DebugCheckUpdateManifest();
|
DebugCheckUpdateManifest();
|
||||||
return _playModeServices.UpdatePackageManifestAsync(packageVersion, autoSaveVersion, timeout);
|
return _playModeServices.UpdatePackageManifestAsync(packageVersion, autoSaveVersion, timeout);
|
||||||
}
|
}
|
||||||
@@ -262,7 +270,7 @@ namespace YooAsset
|
|||||||
/// <param name="timeout">超时时间(默认值:60秒)</param>
|
/// <param name="timeout">超时时间(默认值:60秒)</param>
|
||||||
public PreDownloadContentOperation PreDownloadContentAsync(string packageVersion, int timeout = 60)
|
public PreDownloadContentOperation PreDownloadContentAsync(string packageVersion, int timeout = 60)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize(false);
|
||||||
return _playModeServices.PreDownloadContentAsync(packageVersion, timeout);
|
return _playModeServices.PreDownloadContentAsync(packageVersion, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -294,8 +302,6 @@ namespace YooAsset
|
|||||||
public string GetPackageVersion()
|
public string GetPackageVersion()
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
if (_playModeServices.ActiveManifest == null)
|
|
||||||
return string.Empty;
|
|
||||||
return _playModeServices.ActiveManifest.PackageVersion;
|
return _playModeServices.ActiveManifest.PackageVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -573,6 +579,18 @@ namespace YooAsset
|
|||||||
return LoadAssetInternal(assetInfo, true);
|
return LoadAssetInternal(assetInfo, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 同步加载资源对象
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="location">资源的定位地址</param>
|
||||||
|
public AssetOperationHandle LoadAssetSync(string location)
|
||||||
|
{
|
||||||
|
DebugCheckInitialize();
|
||||||
|
Type type = typeof(UnityEngine.Object);
|
||||||
|
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, type);
|
||||||
|
return LoadAssetInternal(assetInfo, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 异步加载资源对象
|
/// 异步加载资源对象
|
||||||
@@ -608,6 +626,18 @@ namespace YooAsset
|
|||||||
return LoadAssetInternal(assetInfo, false);
|
return LoadAssetInternal(assetInfo, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 异步加载资源对象
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="location">资源的定位地址</param>
|
||||||
|
public AssetOperationHandle LoadAssetAsync(string location)
|
||||||
|
{
|
||||||
|
DebugCheckInitialize();
|
||||||
|
Type type = typeof(UnityEngine.Object);
|
||||||
|
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, type);
|
||||||
|
return LoadAssetInternal(assetInfo, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private AssetOperationHandle LoadAssetInternal(AssetInfo assetInfo, bool waitForAsyncComplete)
|
private AssetOperationHandle LoadAssetInternal(AssetInfo assetInfo, bool waitForAsyncComplete)
|
||||||
{
|
{
|
||||||
@@ -662,6 +692,18 @@ namespace YooAsset
|
|||||||
return LoadSubAssetsInternal(assetInfo, true);
|
return LoadSubAssetsInternal(assetInfo, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 同步加载子资源对象
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="location">资源的定位地址</param>
|
||||||
|
public SubAssetsOperationHandle LoadSubAssetsSync(string location)
|
||||||
|
{
|
||||||
|
DebugCheckInitialize();
|
||||||
|
Type type = typeof(UnityEngine.Object);
|
||||||
|
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, type);
|
||||||
|
return LoadSubAssetsInternal(assetInfo, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 异步加载子资源对象
|
/// 异步加载子资源对象
|
||||||
@@ -697,6 +739,18 @@ namespace YooAsset
|
|||||||
return LoadSubAssetsInternal(assetInfo, false);
|
return LoadSubAssetsInternal(assetInfo, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 异步加载子资源对象
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="location">资源的定位地址</param>
|
||||||
|
public SubAssetsOperationHandle LoadSubAssetsAsync(string location)
|
||||||
|
{
|
||||||
|
DebugCheckInitialize();
|
||||||
|
Type type = typeof(UnityEngine.Object);
|
||||||
|
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, type);
|
||||||
|
return LoadSubAssetsInternal(assetInfo, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private SubAssetsOperationHandle LoadSubAssetsInternal(AssetInfo assetInfo, bool waitForAsyncComplete)
|
private SubAssetsOperationHandle LoadSubAssetsInternal(AssetInfo assetInfo, bool waitForAsyncComplete)
|
||||||
{
|
{
|
||||||
@@ -751,6 +805,18 @@ namespace YooAsset
|
|||||||
return LoadAllAssetsInternal(assetInfo, true);
|
return LoadAllAssetsInternal(assetInfo, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 同步加载资源包内所有资源对象
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="location">资源的定位地址</param>
|
||||||
|
public AllAssetsOperationHandle LoadAllAssetsSync(string location)
|
||||||
|
{
|
||||||
|
DebugCheckInitialize();
|
||||||
|
Type type = typeof(UnityEngine.Object);
|
||||||
|
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, type);
|
||||||
|
return LoadAllAssetsInternal(assetInfo, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 异步加载资源包内所有资源对象
|
/// 异步加载资源包内所有资源对象
|
||||||
@@ -786,6 +852,18 @@ namespace YooAsset
|
|||||||
return LoadAllAssetsInternal(assetInfo, false);
|
return LoadAllAssetsInternal(assetInfo, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 异步加载资源包内所有资源对象
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="location">资源的定位地址</param>
|
||||||
|
public AllAssetsOperationHandle LoadAllAssetsAsync(string location)
|
||||||
|
{
|
||||||
|
DebugCheckInitialize();
|
||||||
|
Type type = typeof(UnityEngine.Object);
|
||||||
|
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, type);
|
||||||
|
return LoadAllAssetsInternal(assetInfo, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private AllAssetsOperationHandle LoadAllAssetsInternal(AssetInfo assetInfo, bool waitForAsyncComplete)
|
private AllAssetsOperationHandle LoadAllAssetsInternal(AssetInfo assetInfo, bool waitForAsyncComplete)
|
||||||
{
|
{
|
||||||
@@ -967,12 +1045,18 @@ namespace YooAsset
|
|||||||
|
|
||||||
#region 调试方法
|
#region 调试方法
|
||||||
[Conditional("DEBUG")]
|
[Conditional("DEBUG")]
|
||||||
private void DebugCheckInitialize()
|
private void DebugCheckInitialize(bool checkActiveManifest = true)
|
||||||
{
|
{
|
||||||
if (_initializeStatus == EOperationStatus.None)
|
if (_initializeStatus == EOperationStatus.None)
|
||||||
throw new Exception("Package initialize not completed !");
|
throw new Exception("Package initialize not completed !");
|
||||||
else if (_initializeStatus == EOperationStatus.Failed)
|
else if (_initializeStatus == EOperationStatus.Failed)
|
||||||
throw new Exception($"Package initialize failed ! {_initializeError}");
|
throw new Exception($"Package initialize failed ! {_initializeError}");
|
||||||
|
|
||||||
|
if (checkActiveManifest)
|
||||||
|
{
|
||||||
|
if (_playModeServices.ActiveManifest == null)
|
||||||
|
throw new Exception("Not found active manifest !");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Conditional("DEBUG")]
|
[Conditional("DEBUG")]
|
||||||
|
|||||||
@@ -1,11 +1,30 @@
|
|||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 分发的资源信息
|
||||||
|
/// </summary>
|
||||||
|
public struct DeliveryFileInfo
|
||||||
|
{
|
||||||
|
public string DeliveryFilePath;
|
||||||
|
public ulong DeliveryFileOffset;
|
||||||
|
}
|
||||||
|
|
||||||
public interface IQueryServices
|
public interface IQueryServices
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查询内置资源
|
/// 查询应用程序里的内置资源是否存在
|
||||||
/// </summary>
|
/// </summary>
|
||||||
bool QueryStreamingAssets(string packageName, string fileName);
|
bool QueryStreamingAssets(string packageName, string fileName);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询是否为开发者分发的资源
|
||||||
|
/// </summary>
|
||||||
|
bool QueryDeliveryFiles(string packageName, string fileName);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取开发者分发的资源信息
|
||||||
|
/// </summary>
|
||||||
|
DeliveryFileInfo GetDeliveryFileInfo(string packageName, string fileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -142,11 +142,11 @@ internal class FsmInitialize : IStateNode
|
|||||||
_defaultHostServer = defaultHostServer;
|
_defaultHostServer = defaultHostServer;
|
||||||
_fallbackHostServer = fallbackHostServer;
|
_fallbackHostServer = fallbackHostServer;
|
||||||
}
|
}
|
||||||
string IRemoteServices.GetRemoteFallbackURL(string fileName)
|
string IRemoteServices.GetRemoteMainURL(string fileName)
|
||||||
{
|
{
|
||||||
return $"{_defaultHostServer}/{fileName}";
|
return $"{_defaultHostServer}/{fileName}";
|
||||||
}
|
}
|
||||||
string IRemoteServices.GetRemoteMainURL(string fileName)
|
string IRemoteServices.GetRemoteFallbackURL(string fileName)
|
||||||
{
|
{
|
||||||
return $"{_fallbackHostServer}/{fileName}";
|
return $"{_fallbackHostServer}/{fileName}";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,10 +4,20 @@ using UnityEngine;
|
|||||||
using YooAsset;
|
using YooAsset;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 内置文件查询服务类
|
/// 资源文件查询服务类
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class GameQueryServices : IQueryServices
|
public class GameQueryServices : IQueryServices
|
||||||
{
|
{
|
||||||
|
public DeliveryFileInfo GetDeliveryFileInfo(string packageName, string fileName)
|
||||||
|
{
|
||||||
|
throw new System.NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool QueryDeliveryFiles(string packageName, string fileName)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public bool QueryStreamingAssets(string packageName, string fileName)
|
public bool QueryStreamingAssets(string packageName, string fileName)
|
||||||
{
|
{
|
||||||
// 注意:fileName包含文件格式
|
// 注意:fileName包含文件格式
|
||||||
|
|||||||
@@ -7,10 +7,20 @@ using YooAsset;
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 内置文件查询服务类
|
/// 资源文件查询服务类
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class GameQueryServices2 : IQueryServices
|
public class GameQueryServices2 : IQueryServices
|
||||||
{
|
{
|
||||||
|
public DeliveryFileInfo GetDeliveryFileInfo(string packageName, string fileName)
|
||||||
|
{
|
||||||
|
throw new System.NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool QueryDeliveryFiles(string packageName, string fileName)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public bool QueryStreamingAssets(string packageName, string fileName)
|
public bool QueryStreamingAssets(string packageName, string fileName)
|
||||||
{
|
{
|
||||||
return StreamingAssetsHelper2.FileExists($"{StreamingAssetsDefine.RootFolderName}/{packageName}/{fileName}");
|
return StreamingAssetsHelper2.FileExists($"{StreamingAssetsDefine.RootFolderName}/{packageName}/{fileName}");
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "com.tuyoogame.yooasset",
|
"name": "com.tuyoogame.yooasset",
|
||||||
"displayName": "YooAsset",
|
"displayName": "YooAsset",
|
||||||
"version": "1.5.2-preview",
|
"version": "1.5.3-preview",
|
||||||
"unity": "2019.4",
|
"unity": "2019.4",
|
||||||
"description": "unity3d resources management system.",
|
"description": "unity3d resources management system.",
|
||||||
"author": {
|
"author": {
|
||||||
|
|||||||
Reference in New Issue
Block a user