Skip to content

Commit

Permalink
upgraded yooasset and added webgl mode
Browse files Browse the repository at this point in the history
  • Loading branch information
michael811125 committed Jul 20, 2023
1 parent c2d6dbe commit 404d027
Show file tree
Hide file tree
Showing 110 changed files with 2,664 additions and 815 deletions.
4 changes: 2 additions & 2 deletions Assets/AssetBundleBuilderSetting.asset
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ MonoBehaviour:
BuildPackage: DefaultPackage
CompressOption: 2
OutputNameStyle: 1
CopyBuildinFileOption: 0
CopyBuildinFileOption: 1
CopyBuildinFileTags:
EncyptionClassName: HT2XorEncryption
EncyptionClassName: EncryptionNone
Binary file modified Assets/HotfixCollector/AOTDlls/UniTask.dll.bytes
Binary file not shown.
Binary file modified Assets/HotfixCollector/AOTDlls/mscorlib.dll.bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Assets/HybridCLRData/Generated/AOTGenericReferences.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ public class AOTGenericReferences : UnityEngine.MonoBehaviour
// }}

// {{ AOT generic types
// Cysharp.Threading.Tasks.UniTask<object>
// Cysharp.Threading.Tasks.UniTask.Awaiter<object>
// Cysharp.Threading.Tasks.UniTask<object>
// System.Func<Cysharp.Threading.Tasks.UniTaskVoid>
// }}

Expand Down
34 changes: 17 additions & 17 deletions Assets/HybridCLRData/Generated/link.xml
Original file line number Diff line number Diff line change
@@ -1,21 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<linker>
<assembly fullname="mscorlib">
<type fullname="System.Diagnostics.DebuggableAttribute" preserve="all" />
<type fullname="System.Diagnostics.DebuggableAttribute/DebuggingModes" preserve="all" />
<type fullname="System.Diagnostics.DebuggerHiddenAttribute" preserve="all" />
<type fullname="System.Exception" preserve="all" />
<type fullname="System.Func`1" preserve="all" />
<type fullname="System.Object" preserve="all" />
<type fullname="System.Runtime.CompilerServices.AsyncStateMachineAttribute" preserve="all" />
<type fullname="System.Runtime.CompilerServices.CompilationRelaxationsAttribute" preserve="all" />
<type fullname="System.Runtime.CompilerServices.CompilerGeneratedAttribute" preserve="all" />
<type fullname="System.Runtime.CompilerServices.IAsyncStateMachine" preserve="all" />
<type fullname="System.Runtime.CompilerServices.RuntimeCompatibilityAttribute" preserve="all" />
<type fullname="System.String" preserve="all" />
<type fullname="System.Type" preserve="all" />
<type fullname="System.ValueType" preserve="all" />
</assembly>
<assembly fullname="OxGFrame.AssetLoader.Runtime">
<type fullname="OxGFrame.AssetLoader.AssetLoaders" preserve="all" />
<type fullname="OxGFrame.AssetLoader.AssetPatcher" preserve="all" />
Expand All @@ -24,9 +8,9 @@
<assembly fullname="UniTask">
<type fullname="Cysharp.Threading.Tasks.CompilerServices.AsyncUniTaskVoidMethodBuilder" preserve="all" />
<type fullname="Cysharp.Threading.Tasks.UniTask" preserve="all" />
<type fullname="Cysharp.Threading.Tasks.UniTaskVoid" preserve="all" />
<type fullname="Cysharp.Threading.Tasks.UniTask`1" preserve="all" />
<type fullname="Cysharp.Threading.Tasks.UniTask`1/Awaiter" preserve="all" />
<type fullname="Cysharp.Threading.Tasks.UniTaskVoid" preserve="all" />
</assembly>
<assembly fullname="UnityEngine.CoreModule">
<type fullname="UnityEngine.GameObject" preserve="all" />
Expand All @@ -35,4 +19,20 @@
<assembly fullname="UnityEngine.UI">
<type fullname="UnityEngine.UI.Text" preserve="all" />
</assembly>
<assembly fullname="mscorlib">
<type fullname="System.Diagnostics.DebuggableAttribute" preserve="all" />
<type fullname="System.Diagnostics.DebuggableAttribute/DebuggingModes" preserve="all" />
<type fullname="System.Diagnostics.DebuggerHiddenAttribute" preserve="all" />
<type fullname="System.Exception" preserve="all" />
<type fullname="System.Func`1" preserve="all" />
<type fullname="System.Object" preserve="all" />
<type fullname="System.Runtime.CompilerServices.AsyncStateMachineAttribute" preserve="all" />
<type fullname="System.Runtime.CompilerServices.CompilationRelaxationsAttribute" preserve="all" />
<type fullname="System.Runtime.CompilerServices.CompilerGeneratedAttribute" preserve="all" />
<type fullname="System.Runtime.CompilerServices.IAsyncStateMachine" preserve="all" />
<type fullname="System.Runtime.CompilerServices.RuntimeCompatibilityAttribute" preserve="all" />
<type fullname="System.String" preserve="all" />
<type fullname="System.Type" preserve="all" />
<type fullname="System.ValueType" preserve="all" />
</assembly>
</linker>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "OxGFrame.AgencyCenter.Editor",
"rootNamespace": "",
"references": [
"GUID:8b348405f7edbc04e94b4ef83f465122"
"GUID:a24dbf7565faccf4bbaa3b675e168c4f"
],
"includePlatforms": [
"Editor"
Expand Down
20 changes: 12 additions & 8 deletions Assets/OxGFrame/AssetLoader/Scripts/Runtime/AssetPatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,9 @@ public static async UniTask<bool> InitAppPackage(string packageName, bool autoUp
string fallbackHostServer = null;
IQueryServices queryService = null;

// Only Host Mode
if (BundleConfig.playMode == BundleConfig.PlayMode.HostMode)
// Host Mode or WebGL Mode
if (BundleConfig.playMode == BundleConfig.PlayMode.HostMode ||
BundleConfig.playMode == BundleConfig.PlayMode.WebGLMode)
{
hostServer = await BundleConfig.GetHostServerUrl(packageName);
fallbackHostServer = await BundleConfig.GetFallbackHostServerUrl(packageName);
Expand All @@ -236,8 +237,9 @@ public static async UniTask<bool> InitAppPackage(int idx, bool autoUpdate = fals
string fallbackHostServer = null;
IQueryServices queryService = null;

// Only Host Mode
if (BundleConfig.playMode == BundleConfig.PlayMode.HostMode)
// Host Mode or WebGL Mode
if (BundleConfig.playMode == BundleConfig.PlayMode.HostMode ||
BundleConfig.playMode == BundleConfig.PlayMode.WebGLMode)
{
hostServer = await BundleConfig.GetHostServerUrl(packageName);
fallbackHostServer = await BundleConfig.GetFallbackHostServerUrl(packageName);
Expand All @@ -262,8 +264,9 @@ public static async UniTask<bool> InitDlcPackage(string packageName, string dlcV
string fallbackHostServer = null;
IQueryServices queryService = null;

// Only Host Mode
if (BundleConfig.playMode == BundleConfig.PlayMode.HostMode)
// Host Mode or WebGL Mode
if (BundleConfig.playMode == BundleConfig.PlayMode.HostMode ||
BundleConfig.playMode == BundleConfig.PlayMode.WebGLMode)
{
hostServer = await BundleConfig.GetDlcHostServerUrl(packageName, dlcVersion);
fallbackHostServer = await BundleConfig.GetDlcFallbackHostServerUrl(packageName, dlcVersion);
Expand All @@ -286,8 +289,9 @@ public static async UniTask<bool> InitDlcPackage(string packageName, string dlcV
string hostServer = null;
string fallbackHostServer = null;

// Only Host Mode
if (BundleConfig.playMode == BundleConfig.PlayMode.HostMode)
// Host Mode or WebGL Mode
if (BundleConfig.playMode == BundleConfig.PlayMode.HostMode ||
BundleConfig.playMode == BundleConfig.PlayMode.WebGLMode)
{
hostServer = await BundleConfig.GetDlcHostServerUrl(packageName, dlcVersion);
fallbackHostServer = await BundleConfig.GetDlcFallbackHostServerUrl(packageName, dlcVersion);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ public enum PlayMode
{
EditorSimulateMode,
OfflineMode,
HostMode
HostMode,
WebGLMode
}

public class CryptogramType
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using Cysharp.Threading.Tasks;
using OxGFrame.AssetLoader.Utility;
using System;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using YooAsset;

Expand All @@ -22,7 +20,7 @@ public static void InitSetup()
#region Init YooAssets
YooAssets.Destroy();
YooAssets.Initialize();
YooAssets.SetOperationSystemMaxTimeSlice(10);
YooAssets.SetOperationSystemMaxTimeSlice(30);
#endregion

#region Init Decryption Type
Expand Down Expand Up @@ -73,8 +71,9 @@ public static async UniTask<bool> InitDefaultPackage()
string fallbackHostServer = null;
IQueryServices queryService = null;

// Only Host Mode
if (BundleConfig.playMode == BundleConfig.PlayMode.HostMode)
// Host Mode or WebGL Mode
if (BundleConfig.playMode == BundleConfig.PlayMode.HostMode ||
BundleConfig.playMode == BundleConfig.PlayMode.WebGLMode)
{
hostServer = await BundleConfig.GetHostServerUrl(_currentPackageName);
fallbackHostServer = await BundleConfig.GetFallbackHostServerUrl(_currentPackageName);
Expand Down Expand Up @@ -130,6 +129,16 @@ public static async UniTask<bool> InitPackage(string packageName, bool autoUpdat
initializationOperation = package.InitializeAsync(createParameters);
}

// WebGL Mode
if (BundleConfig.playMode == BundleConfig.PlayMode.WebGLMode)
{
var createParameters = new WebPlayModeParameters();
createParameters.DecryptionServices = _decryption;
createParameters.QueryServices = queryService;
createParameters.RemoteServices = new HostServers(hostServer, fallbackHostServer);
initializationOperation = package.InitializeAsync(createParameters);
}

await initializationOperation;

if (initializationOperation.Status == EOperationStatus.Succeed)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
using UnityEngine;
using YooAsset;

#if UNITY_EDITOR
using UnityEditor;
#endif

namespace OxGFrame.AssetLoader.Bundle
{
[DisallowMultipleComponent]
Expand All @@ -12,7 +16,7 @@ internal class PatchLauncher : MonoBehaviour

[Header("Patch Options")]
public BundleConfig.PlayMode playMode = BundleConfig.PlayMode.EditorSimulateMode;
[Tooltip("If checker patch field will compare whole version"), ConditionalField(nameof(playMode), false, BundleConfig.PlayMode.HostMode)]
[Tooltip("If checker patch field will compare whole version"), ConditionalField(nameof(playMode), false, BundleConfig.PlayMode.HostMode, BundleConfig.PlayMode.WebGLMode)]
public BundleConfig.SemanticRule semanticRule = new BundleConfig.SemanticRule();
[Tooltip("If checked will skip default package download step of patch (force download while playing)"), ConditionalField(nameof(playMode), false, BundleConfig.PlayMode.HostMode)]
public bool skipCreateMainDownloder = false;
Expand Down Expand Up @@ -49,13 +53,21 @@ private async void Awake()
this.playMode = BundleConfig.PlayMode.OfflineMode;
#elif !UNITY_EDITOR && OXGFRAME_HOST_MODE
this.playMode = BundleConfig.PlayMode.HostMode;
#elif !UNITY_EDITOR && OXGFRAME_WEBGL_MODE
this.playMode = BundleConfig.PlayMode.WebGLMode;
#endif
BundleConfig.playMode = this.playMode;
// For Host Mode
if (this.playMode == BundleConfig.PlayMode.HostMode)
{
BundleConfig.semanticRule = this.semanticRule;
BundleConfig.skipCreateMainDownloder = this.skipCreateMainDownloder;
}
// For WebGL Mode
else if (this.playMode == BundleConfig.PlayMode.WebGLMode)
{
BundleConfig.semanticRule = this.semanticRule;
}
#endregion

#region Package List
Expand Down Expand Up @@ -88,9 +100,36 @@ private async void Awake()

private void OnApplicationQuit()
{
#if !UNITY_WEBGL
PackageManager.Release();

Debug.Log("<color=#ff84d1>(Powered by YooAsset) Release Packages Completes.</color>");
#endif
}

#if UNITY_EDITOR
private void OnValidate()
{
#if UNITY_WEBGL
switch (this.playMode)
{
case BundleConfig.PlayMode.OfflineMode:

Debug.Log($"<color=#ff1f4c>[Offline Mode] is not supported on {EditorUserBuildSettings.activeBuildTarget}.</color>");
break;
case BundleConfig.PlayMode.HostMode:
Debug.Log($"<color=#ff1f4c>[Host Mode] is not supported on {EditorUserBuildSettings.activeBuildTarget}.</color>");
break;
}
#else
switch (this.playMode)
{
case BundleConfig.PlayMode.WebGLMode:

Debug.Log($"<color=#ff1f4c>[WebGL Mode] is not supported on {EditorUserBuildSettings.activeBuildTarget}.</color>");
break;
}
#endif
}
#endif
}
}
Loading

0 comments on commit 404d027

Please sign in to comment.