mirror of https://github.com/tuyoogame/YooAsset
fix #456
parent
203b9994df
commit
0b5d16bd0e
|
@ -34,14 +34,20 @@ namespace YooAsset
|
|||
DirectoryInfo[] subDirectories = rootDirectory.GetDirectories();
|
||||
foreach (var subDirectory in subDirectories)
|
||||
{
|
||||
CreateBuildinCatalogFile(subDirectory.Name, subDirectory.FullName);
|
||||
string packageName = subDirectory.Name;
|
||||
string pacakgeDirectory = subDirectory.FullName;
|
||||
bool result = CreateBuildinCatalogFile(packageName, pacakgeDirectory);
|
||||
if (result == false)
|
||||
{
|
||||
throw new System.Exception($"Create package {packageName} catalog file failed ! See the detail error in console !");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生成包裹的内置资源目录文件
|
||||
/// </summary>
|
||||
public static void CreateBuildinCatalogFile(string packageName, string pacakgeDirectory)
|
||||
public static bool CreateBuildinCatalogFile(string packageName, string pacakgeDirectory)
|
||||
{
|
||||
// 获取资源清单版本
|
||||
string packageVersion;
|
||||
|
@ -50,7 +56,8 @@ namespace YooAsset
|
|||
string versionFilePath = $"{pacakgeDirectory}/{versionFileName}";
|
||||
if (File.Exists(versionFilePath) == false)
|
||||
{
|
||||
throw new System.Exception($"Can not found package version file : {versionFilePath}");
|
||||
Debug.LogError($"Can not found package version file : {versionFilePath}");
|
||||
return false;
|
||||
}
|
||||
|
||||
packageVersion = FileUtility.ReadAllText(versionFilePath);
|
||||
|
@ -63,7 +70,8 @@ namespace YooAsset
|
|||
string manifestFilePath = $"{pacakgeDirectory}/{manifestFileName}";
|
||||
if (File.Exists(manifestFilePath) == false)
|
||||
{
|
||||
throw new System.Exception($"Can not found package manifest file : {manifestFilePath}");
|
||||
Debug.LogError($"Can not found package manifest file : {manifestFilePath}");
|
||||
return false;
|
||||
}
|
||||
|
||||
var binaryData = FileUtility.ReadAllBytes(manifestFilePath);
|
||||
|
@ -117,10 +125,12 @@ namespace YooAsset
|
|||
}
|
||||
}
|
||||
|
||||
// 创建输出目录
|
||||
string fullPath = YooAssetSettingsData.GetYooResourcesFullPath();
|
||||
string saveFilePath = $"{fullPath}/{packageName}/{DefaultBuildinFileSystemDefine.BuildinCatalogFileName}";
|
||||
FileUtility.CreateFileDirectory(saveFilePath);
|
||||
|
||||
// 创建输出文件
|
||||
UnityEditor.AssetDatabase.CreateAsset(buildinFileCatalog, saveFilePath);
|
||||
UnityEditor.EditorUtility.SetDirty(buildinFileCatalog);
|
||||
#if UNITY_2019
|
||||
|
@ -128,7 +138,9 @@ namespace YooAsset
|
|||
#else
|
||||
UnityEditor.AssetDatabase.SaveAssetIfDirty(buildinFileCatalog);
|
||||
#endif
|
||||
|
||||
Debug.Log($"Succeed to save buildin file catalog : {saveFilePath}");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,7 +74,14 @@ namespace YooAsset
|
|||
// 兼容性初始化
|
||||
// 说明:内置文件系统在编辑器下运行时需要动态生成
|
||||
string packageRoot = _fileSystem.FileRoot;
|
||||
DefaultBuildinFileSystemBuild.CreateBuildinCatalogFile(_fileSystem.PackageName, packageRoot);
|
||||
bool result = DefaultBuildinFileSystemBuild.CreateBuildinCatalogFile(_fileSystem.PackageName, packageRoot);
|
||||
if (result == false)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"Create package catalog file failed ! See the detail error in console !";
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
_loadCatalogFileOp = new LoadBuildinCatalogFileOperation(_fileSystem);
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
|
||||
using static UnityEngine.Networking.UnityWebRequest;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class DWSFSInitializeOperation : FSInitializeFileSystemOperation
|
||||
|
@ -37,7 +39,14 @@ namespace YooAsset
|
|||
// 说明:内置文件系统在编辑器下运行时需要动态生成
|
||||
string buildinRoot = YooAssetSettingsData.GetYooEditorBuildinRoot();
|
||||
string packageRoot = PathUtility.Combine(buildinRoot, _fileSystem.PackageName);
|
||||
DefaultBuildinFileSystemBuild.CreateBuildinCatalogFile(_fileSystem.PackageName, packageRoot);
|
||||
bool result = DefaultBuildinFileSystemBuild.CreateBuildinCatalogFile(_fileSystem.PackageName, packageRoot);
|
||||
if (result == false)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"Create package catalog file failed ! See the detail error in console !";
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
_loadCatalogFileOp = new LoadWebServerCatalogFileOperation(_fileSystem);
|
||||
|
|
|
@ -6,6 +6,7 @@ namespace YooAsset
|
|||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
CheckInitStatus,
|
||||
UnloadAllAssets,
|
||||
DestroyPackage,
|
||||
Done,
|
||||
|
@ -23,13 +24,42 @@ namespace YooAsset
|
|||
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
_steps = ESteps.UnloadAllAssets;
|
||||
_steps = ESteps.CheckInitStatus;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.CheckInitStatus)
|
||||
{
|
||||
if (_resourcePackage.InitializeStatus == EOperationStatus.None)
|
||||
{
|
||||
_steps = ESteps.DestroyPackage;
|
||||
}
|
||||
else if (_resourcePackage.InitializeStatus == EOperationStatus.Processing)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = "The Package is initializing ! Please try to destroy the package again later.";
|
||||
}
|
||||
else if (_resourcePackage.InitializeStatus == EOperationStatus.Failed)
|
||||
{
|
||||
_steps = ESteps.DestroyPackage;
|
||||
}
|
||||
else if (_resourcePackage.InitializeStatus == EOperationStatus.Succeed)
|
||||
{
|
||||
if (_resourcePackage.PackageValid)
|
||||
_steps = ESteps.UnloadAllAssets;
|
||||
else
|
||||
_steps = ESteps.DestroyPackage;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new System.NotImplementedException(_resourcePackage.InitializeStatus.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.UnloadAllAssets)
|
||||
{
|
||||
if (_unloadAllAssetsOp == null)
|
||||
|
|
|
@ -31,6 +31,19 @@ namespace YooAsset
|
|||
get { return _initializeStatus; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 包裹是否有效
|
||||
/// </summary>
|
||||
public bool PackageValid
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_playModeImpl == null)
|
||||
return false;
|
||||
return _playModeImpl.ActiveManifest != null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
internal ResourcePackage(string packageName)
|
||||
{
|
||||
|
@ -258,7 +271,7 @@ namespace YooAsset
|
|||
DebugCheckInitialize();
|
||||
return _playModeImpl.ClearCacheFilesAsync(clearMode.ToString(), clearParam);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 清理缓存文件
|
||||
/// </summary>
|
||||
|
|
Loading…
Reference in New Issue