Skip to content

Commit

Permalink
added API and updated third-party
Browse files Browse the repository at this point in the history
  • Loading branch information
michael811125 committed Aug 14, 2023
1 parent 392bf10 commit 2bc12fe
Show file tree
Hide file tree
Showing 28 changed files with 600 additions and 280 deletions.
317 changes: 313 additions & 4 deletions Assets/OxGFrame/AssetLoader/Scripts/Runtime/AssetPatcher.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public static async UniTask<bool> InitPresetAppPackages()
// Init preset app package
string hostServer = null;
string fallbackHostServer = null;
IQueryServices queryService = null;
IBuildinQueryServices queryService = null;

// Host Mode or WebGL Mode
if (BundleConfig.playMode == BundleConfig.PlayMode.HostMode ||
Expand All @@ -103,7 +103,7 @@ public static async UniTask<bool> InitPresetAppPackages()
/// <param name="fallbackHostServer"></param>
/// <param name="queryService"></param>
/// <returns></returns>
public static async UniTask<bool> InitPackage(string packageName, bool autoUpdate, string hostServer, string fallbackHostServer, IQueryServices queryService)
public static async UniTask<bool> InitPackage(string packageName, bool autoUpdate, string hostServer, string fallbackHostServer, IBuildinQueryServices queryService)
{
var package = RegisterPackage(packageName);
if (package.InitializeStatus == EOperationStatus.Succeed)
Expand Down Expand Up @@ -135,7 +135,7 @@ public static async UniTask<bool> InitPackage(string packageName, bool autoUpdat
{
var createParameters = new HostPlayModeParameters();
createParameters.DecryptionServices = _decryption;
createParameters.QueryServices = queryService;
createParameters.BuildinQueryServices = queryService;
createParameters.RemoteServices = new HostServers(hostServer, fallbackHostServer);
initializationOperation = package.InitializeAsync(createParameters);
}
Expand All @@ -145,7 +145,7 @@ public static async UniTask<bool> InitPackage(string packageName, bool autoUpdat
{
var createParameters = new WebPlayModeParameters();
createParameters.DecryptionServices = _decryption;
createParameters.QueryServices = queryService;
createParameters.BuildinQueryServices = queryService;
createParameters.RemoteServices = new HostServers(hostServer, fallbackHostServer);
initializationOperation = package.InitializeAsync(createParameters);
}
Expand Down Expand Up @@ -390,6 +390,28 @@ public static ResourcePackage GetPackage(string packageName)
return YooAssets.TryGetPackage(packageName);
}

/// <summary>
/// Get packages by package names
/// </summary>
/// <param name="packageNames"></param>
/// <returns></returns>
public static ResourcePackage[] GetPackages(string[] packageNames)
{
if (packageNames != null && packageNames.Length > 0)
{
List<ResourcePackage> packages = new List<ResourcePackage>();
foreach (string packageName in packageNames)
{
var package = GetPackage(packageName);
if (package != null) packages.Add(package);
}

return packages.ToArray();
}

return null;
}

/// <summary>
/// Get preset app packages
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace OxGFrame.AssetLoader.Bundle
{
public abstract class RequestQueryBase : IQueryServices
public abstract class RequestQueryBase : IBuildinQueryServices
{
public DeliveryFileInfo GetDeliveryFileInfo(string packageName, string fileName)
{
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,10 @@ public List<CollectAssetInfo> GetAllCollectAssets(CollectCommand command, AssetB
{
string address = collectInfoPair.Value.Address;
string assetPath = collectInfoPair.Value.AssetPath;

if (address.StartsWith("Assets/") || address.StartsWith("assets/"))
throw new Exception($"The address can not set asset path in collector : {CollectPath} \nAssetPath: {assetPath}");

if (addressTemper.TryGetValue(address, out var existed) == false)
addressTemper.Add(address, assetPath);
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class AddressByFilePath : IAddressRule
{
string IAddressRule.GetAssetAddress(AddressRuleData data)
{
return data.AssetPath;
throw new System.Exception("可寻址模式下已经默认支持通过资源路径加载!");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,16 @@ public EOperationStatus Status
{
if (IsValidWithWarning == false)
return EOperationStatus.None;
if (Provider.Status == ProviderBase.EStatus.Failed)
return EOperationStatus.Failed;
else if (Provider.Status == ProviderBase.EStatus.Succeed)

var status = Provider.Status;
if (status == ProviderBase.EStatus.None)
return EOperationStatus.None;
else if (status == ProviderBase.EStatus.Succeed)
return EOperationStatus.Succeed;
else if (status == ProviderBase.EStatus.Failed)
return EOperationStatus.Failed;
else
return EOperationStatus.None;
return EOperationStatus.Processing;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,12 @@ public class HostPlayModeParameters : InitializeParameters
/// <summary>
/// 内置资源查询服务接口
/// </summary>
public IQueryServices QueryServices = null;
public IBuildinQueryServices BuildinQueryServices = null;

/// <summary>
/// 分发资源查询服务接口
/// </summary>
public IDeliveryQueryServices DeliveryQueryServices = null;

/// <summary>
/// 远端资源地址查询服务类
Expand All @@ -104,7 +109,7 @@ public class WebPlayModeParameters : InitializeParameters
/// <summary>
/// 内置资源查询服务接口
/// </summary>
public IQueryServices QueryServices = null;
public IBuildinQueryServices BuildinQueryServices = null;

/// <summary>
/// 远端资源地址查询服务类
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,18 @@ public Task Task

internal abstract void Start();
internal abstract void Update();
internal void Finish()

internal void OnFinish()
{
Progress = 1f;
_callback?.Invoke(this);
if (_taskCompletionSource != null)
_taskCompletionSource.TrySetResult(null);
}
internal void OnStart()
{
Status = EOperationStatus.Processing;
}

/// <summary>
/// 清空完成回调
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ namespace YooAsset
public enum EOperationStatus
{
None,
Processing,
Succeed,
Failed
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static void Update()
if (operation.IsDone)
{
_removeList.Add(operation);
operation.Finish();
operation.OnFinish();
}
}

Expand Down Expand Up @@ -101,6 +101,7 @@ public static void DestroyAll()
public static void StartOperation(AsyncOperationBase operation)
{
_addList.Add(operation);
operation.OnStart();
operation.Start();
}
}
Expand Down
Loading

0 comments on commit 2bc12fe

Please sign in to comment.