Skip to content

Commit

Permalink
updated to v2.9.9
Browse files Browse the repository at this point in the history
  • Loading branch information
michael811125 committed Dec 17, 2023
1 parent c84b3ac commit 39e88f3
Show file tree
Hide file tree
Showing 32 changed files with 8,196 additions and 172 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
using Newtonsoft.Json;
using OxGFrame.AssetLoader.Bundle;
using OxGFrame.AssetLoader.Utility;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEditor;
using UnityEngine;
using OxGFrame.AssetLoader.Utility;
using YooAsset.Editor;
using YooAsset;
using System.Linq;
using System;

namespace OxGFrame.AssetLoader.Editor
{
Expand Down
68 changes: 11 additions & 57 deletions Assets/OxGFrame/AssetLoader/Scripts/Runtime/AssetPatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using OxGFrame.AssetLoader.Bundle;
using OxGFrame.AssetLoader.Utility;
using System.Collections.Generic;
using UnityEngine;
using YooAsset;
using static OxGFrame.AssetLoader.Utility.DownloadSpeedCalculator;
using static YooAsset.DownloaderOperation;
Expand Down Expand Up @@ -183,10 +184,9 @@ public static string GetAppVersion()
/// <returns></returns>
public static string GetPatchVersion(bool encode = false, int encodeLength = 6, string separator = "-")
{
string patchVersion = (PatchManager.patchVersions != null &&
PatchManager.patchVersions.Length > 0) ?
PatchManager.patchVersions[0] :
string.Empty;
string[] versions = PatchManager.patchVersions;
string newestVersion = BundleUtility.NewestPackageVersion(versions);
string patchVersion = string.IsNullOrEmpty(newestVersion) ? string.Empty : newestVersion;

if (encode)
{
Expand Down Expand Up @@ -269,46 +269,18 @@ public static async UniTask<bool> InitAppPackage(AppPackageInfoWithBuild package
/// <returns></returns>
public static async UniTask<bool> InitDlcPackage(DlcPackageInfoWithBuild packageInfo, bool autoUpdate = false)
{
string hostServer = null;
string fallbackHostServer = null;
IBuildinQueryServices builtinQueryService = null;
IDeliveryQueryServices deliveryQueryService = null;
IDeliveryLoadServices deliveryLoadService = null;
string hostServer = packageInfo.hostServer;
string fallbackHostServer = packageInfo.fallbackHostServer;
IBuildinQueryServices builtinQueryService = packageInfo.builtinQueryService;
IDeliveryQueryServices deliveryQueryService = packageInfo.deliveryQueryService;
IDeliveryLoadServices deliveryLoadService = packageInfo.deliveryLoadService;

// Host Mode or WebGL Mode
if (BundleConfig.playMode == BundleConfig.PlayMode.HostMode ||
BundleConfig.playMode == BundleConfig.PlayMode.WebGLMode)
{
hostServer = await BundleConfig.GetDlcHostServerUrl(packageInfo.packageName, packageInfo.dlcVersion, packageInfo.withoutPlatform);
fallbackHostServer = await BundleConfig.GetDlcFallbackHostServerUrl(packageInfo.packageName, packageInfo.dlcVersion, packageInfo.withoutPlatform);
builtinQueryService = new RequestBuiltinQuery();
deliveryQueryService = new RequestDeliveryQuery();
deliveryLoadService = new RequestDeliveryQuery();
}

return await PackageManager.InitPackage(packageInfo, autoUpdate, hostServer, fallbackHostServer, builtinQueryService, deliveryQueryService, deliveryLoadService);
}

/// <summary>
/// Init dlc package (If PlayMode is HostMode will request from default host dlc path)
/// </summary>
/// <param name="packageInfo"></param>
/// <param name="autoUpdate"></param>
/// <param name="builtinQueryService"></param>
/// <param name="deliveryQueryService"></param>
/// <param name="deliveryLoadService"></param>
/// <returns></returns>
public static async UniTask<bool> InitDlcPackage(DlcPackageInfoWithBuild packageInfo, bool autoUpdate = false, IBuildinQueryServices builtinQueryService = null, IDeliveryQueryServices deliveryQueryService = null, IDeliveryLoadServices deliveryLoadService = null)
{
string hostServer = null;
string fallbackHostServer = null;

// Host Mode or WebGL Mode
if (BundleConfig.playMode == BundleConfig.PlayMode.HostMode ||
BundleConfig.playMode == BundleConfig.PlayMode.WebGLMode)
{
hostServer = await BundleConfig.GetDlcHostServerUrl(packageInfo.packageName, packageInfo.dlcVersion, packageInfo.withoutPlatform);
fallbackHostServer = await BundleConfig.GetDlcFallbackHostServerUrl(packageInfo.packageName, packageInfo.dlcVersion, packageInfo.withoutPlatform);
hostServer = string.IsNullOrEmpty(hostServer) ? await BundleConfig.GetDlcHostServerUrl(packageInfo.packageName, packageInfo.dlcVersion, packageInfo.withoutPlatform) : hostServer;
fallbackHostServer = string.IsNullOrEmpty(fallbackHostServer) ? await BundleConfig.GetDlcFallbackHostServerUrl(packageInfo.packageName, packageInfo.dlcVersion, packageInfo.withoutPlatform) : fallbackHostServer;
builtinQueryService = builtinQueryService == null ? new RequestBuiltinQuery() : builtinQueryService;
deliveryQueryService = deliveryQueryService == null ? new RequestDeliveryQuery() : deliveryQueryService;
deliveryLoadService = deliveryLoadService == null ? new RequestDeliveryQuery() : deliveryLoadService;
Expand All @@ -318,24 +290,6 @@ public static async UniTask<bool> InitDlcPackage(DlcPackageInfoWithBuild package
}
#endregion

#region Custom Package
/// <summary>
/// Init package by package name (Custom your host path and query service)
/// </summary>
/// <param name="packageInfo"></param>
/// <param name="hostServer"></param>
/// <param name="fallbackHostServer"></param>
/// <param name="autoUpdate"></param>
/// <param name="builtinQueryService"></param>
/// <param name="deliveryQueryService"></param>
/// <param name="deliveryLoadService"></param>
/// <returns></returns>
public static async UniTask<bool> InitCustomPackage(PackageInfoWithBuild packageInfo, string hostServer, string fallbackHostServer, bool autoUpdate, IBuildinQueryServices builtinQueryService, IDeliveryQueryServices deliveryQueryService, IDeliveryLoadServices deliveryLoadService)
{
return await PackageManager.InitPackage(packageInfo, autoUpdate, hostServer, fallbackHostServer, builtinQueryService, deliveryQueryService, deliveryLoadService);
}
#endregion

#region Update Package
/// <summary>
/// Update package manifest by package name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public class CryptogramType
/// <summary>
/// 跳過 Patch 創建主要下載器階段 (強制邊玩邊下載)
/// </summary>
public static bool skipCreateMainDownloder = false;
public static bool skipMainDownload = false;

/// <summary>
/// App Preset Package 清單
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using YooAsset;
using static OxGFrame.AssetLoader.Bundle.BundleConfig;

namespace OxGFrame.AssetLoader.Bundle
Expand Down Expand Up @@ -54,11 +55,25 @@ public class GroupInfo
}

[Serializable]
public class PackageInfoWithBuild
public abstract class PackageInfoWithBuild
{
[Tooltip("Only for EditorSimulateMode")]
public BuildMode buildMode;
public string packageName;

/// <summary>
/// Custom host server
/// </summary>
[HideInInspector]
public string hostServer = null;
/// <summary>
/// Custom fallback host server
/// </summary>
[HideInInspector]
public string fallbackHostServer = null;
public IBuildinQueryServices builtinQueryService = null;
public IDeliveryQueryServices deliveryQueryService = null;
public IDeliveryLoadServices deliveryLoadService = null;
}

[Serializable]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public async static UniTask InitSetup()
#region Init Preset Packages
bool appInitialized = await InitPresetAppPackages();
bool dlcInitialized = await InitPresetDlcPackages();
Logging.Print<Logger>($"<color=#ffe45a>{appInitialized} {dlcInitialized}</color>");
isInitialized = dlcInitialized && appInitialized;
#endregion

Expand Down Expand Up @@ -133,9 +134,11 @@ public static async UniTask<bool> InitPackage(PackageInfoWithBuild packageInfo,
var package = RegisterPackage(packageName);
if (package.InitializeStatus == EOperationStatus.Succeed)
{
if (autoUpdate) await UpdatePackage(packageName);
// updated state default is true
bool updated = true;
if (autoUpdate) updated = await UpdatePackage(packageName);
Logging.Print<Logger>($"<color=#e2ec00>Package: {packageName} is initialized. Status: {package.InitializeStatus}.</color>");
return true;
return updated;
}

// Simulate Mode
Expand Down Expand Up @@ -193,9 +196,11 @@ public static async UniTask<bool> InitPackage(PackageInfoWithBuild packageInfo,

if (initializationOperation.Status == EOperationStatus.Succeed)
{
if (autoUpdate) await UpdatePackage(packageName);
// updated state default is true
bool updated = true;
if (autoUpdate) updated = await UpdatePackage(packageName);
Logging.Print<Logger>($"<color=#85cf0f>Package: {packageName} <color=#00c1ff>Init</color> completed successfully.</color>");
return true;
return updated;
}
else
{
Expand Down Expand Up @@ -275,17 +280,17 @@ public static bool CheckPackageHasAnyFilesInLocal(string packageName)
/// <returns></returns>
public static ulong GetPackageSizeInLocal(string packageName)
{
if (BundleConfig.playMode == BundleConfig.PlayMode.EditorSimulateMode)
{
Logging.Print<Logger>($"<color=#ffce00><color=#0fa>[{BundleConfig.PlayMode.EditorSimulateMode}]</color> Get Package Size In Local <color=#0fa>return 1</color></color>");
return 1;
}

try
{
var package = GetPackage(packageName);
if (package == null) return 0;

if (BundleConfig.playMode == BundleConfig.PlayMode.EditorSimulateMode)
{
Logging.Print<Logger>($"<color=#ffce00><color=#0fa>[{BundleConfig.PlayMode.EditorSimulateMode}]</color> Get Package Size In Local <color=#0fa>return 1</color></color>");
return 1;
}

string path = BundleConfig.GetLocalSandboxPackagePath(packageName);
if (!Directory.Exists(path)) return 0;

Expand Down
Loading

0 comments on commit 39e88f3

Please sign in to comment.