Skip to content

Commit

Permalink
added methods
Browse files Browse the repository at this point in the history
  • Loading branch information
michael811125 committed Aug 7, 2023
1 parent ddd8fc6 commit 392bf10
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Assets/AssetBundleBuilderSetting.asset
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ MonoBehaviour:
m_EditorClassIdentifier:
BuildPipeline: 1
BuildMode: 1
BuildPackage: DefaultPackage
BuildPackage: OtherPackage
CompressOption: 2
OutputNameStyle: 1
CopyBuildinFileOption: 1
CopyBuildinFileOption: 0
CopyBuildinFileTags:
EncyptionClassName: EncryptionNone
20 changes: 20 additions & 0 deletions Assets/OxGFrame/AssetLoader/Scripts/Runtime/AssetPatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,26 @@ public static string GetPatchVersion(bool encode = false, int encodeLength = 6,
#endregion

#region Package Operation
/// <summary>
/// Check package has any files in local
/// </summary>
/// <param name="packageName"></param>
/// <returns></returns>
public static bool CheckPackageHasAnyFilesInLocal(string packageName)
{
return PackageManager.CheckPackageHasAnyFilesInLocal(packageName);
}

/// <summary>
/// Get package files size in local
/// </summary>
/// <param name="packageName"></param>
/// <returns></returns>
public static ulong GetPackageSizeInLocal(string packageName)
{
return PackageManager.GetPackageSizeInLocal(packageName);
}

/// <summary>
/// Unload package and clear package files from sandbox
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using Cysharp.Threading.Tasks;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEngine;
using YooAsset;

Expand Down Expand Up @@ -197,6 +199,66 @@ public static async UniTask<bool> UpdatePackage(string packageName)
}
}

/// <summary>
/// Check package has any files in local
/// </summary>
/// <param name="packageName"></param>
/// <returns></returns>
public static bool CheckPackageHasAnyFilesInLocal(string packageName)
{
if (BundleConfig.playMode == BundleConfig.PlayMode.EditorSimulateMode)
{
Debug.Log($"<color=#ffce00><color=#0fa>[{BundleConfig.PlayMode.EditorSimulateMode}]</color> Check Package In Local <color=#0fa>return true</color></color>");
return true;
}

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

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

DirectoryInfo directoryInfo = new DirectoryInfo(path);
return directoryInfo.GetFiles("*.*", SearchOption.AllDirectories).Any();
}
catch
{
return false;
}
}

/// <summary>
/// Get package files size in local
/// </summary>
/// <param name="packageName"></param>
/// <returns></returns>
public static ulong GetPackageSizeInLocal(string packageName)
{
if (BundleConfig.playMode == BundleConfig.PlayMode.EditorSimulateMode)
{
Debug.Log($"<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;

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

DirectoryInfo directoryInfo = new DirectoryInfo(path);
return (ulong)directoryInfo.GetFiles("*.*", SearchOption.AllDirectories).Sum(fi => fi.Length);
}
catch
{
return 0;
}
}

/// <summary>
/// Unload package and clear package files from sandbox
/// </summary>
Expand Down
4 changes: 4 additions & 0 deletions Assets/OxGFrame/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## [2.7.2] - 2023-08-07
- Added CheckPackageHasAnyFilesInLocal(string packageName).
- Added GetPackageSizeInLocal(string packageName).

## [2.7.1] - 2023-08-05
- Added Default API in GSIManagerBase (protected GetInstance() method).
```
Expand Down
2 changes: 1 addition & 1 deletion Assets/OxGFrame/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "com.michaelo.oxgframe",
"displayName": "OxGFrame",
"description": "The OxGFrame is a framework based on Unity for accelerating game development. Supports multi-platform Win, Android, iOS, WebGL.",
"version": "2.7.1",
"version": "2.7.2",
"unity": "2021.3",
"license": "MIT",
"samples": [
Expand Down

0 comments on commit 392bf10

Please sign in to comment.