Compare commits

...

4 Commits

Author SHA1 Message Date
何冠峰 9d07905f2d fix #471 2025-02-13 20:14:33 +08:00
何冠峰 26dbe9dfdd update extension sample 2025-02-13 19:08:23 +08:00
何冠峰 98c5851071 update extension file system
解决微信小游戏预下载和正常下载冲突的问题
2025-02-13 18:57:39 +08:00
何冠峰 a6ee571d65 update file system 2025-02-13 18:56:24 +08:00
11 changed files with 40 additions and 20 deletions

View File

@ -2,7 +2,7 @@
<ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;">
<YooAsset.Editor.TableView name="TopTableView" />
</ui:VisualElement>
<ui:VisualElement name="BottomGroup" style="height: 200px; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 1px; margin-bottom: 1px; display: flex;">
<ui:VisualElement name="BottomGroup" style="height: 200px; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 1px; margin-bottom: 1px; display: flex; flex-grow: 1;">
<YooAsset.Editor.TableView name="BottomTableView" />
</ui:VisualElement>
</ui:UXML>

View File

@ -1,8 +1,8 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
<ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;">
<YooAsset.Editor.TableView name="TopTableView" />
<YooAsset.Editor.TableView name="TopTableView" style="flex-grow: 1;" />
</ui:VisualElement>
<ui:VisualElement name="BottomGroup" style="height: 200px; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 1px; margin-bottom: 1px; display: flex;">
<YooAsset.Editor.TableView name="BottomTableView" />
<ui:VisualElement name="BottomGroup" style="height: 200px; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 1px; margin-bottom: 1px; display: flex; flex-grow: 1;">
<YooAsset.Editor.TableView name="BottomTableView" style="flex-grow: 1;" />
</ui:VisualElement>
</ui:UXML>

View File

@ -1,8 +1,8 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
<ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;">
<YooAsset.Editor.TableView name="TopTableView" />
<YooAsset.Editor.TableView name="TopTableView" style="flex-grow: 1;" />
</ui:VisualElement>
<ui:VisualElement name="BottomGroup" style="height: 200px; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 1px; margin-bottom: 1px; display: flex;">
<YooAsset.Editor.TableView name="BottomTableView" />
<ui:VisualElement name="BottomGroup" style="height: 200px; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 1px; margin-bottom: 1px; display: flex; flex-grow: 1;">
<YooAsset.Editor.TableView name="BottomTableView" style="flex-grow: 1;" />
</ui:VisualElement>
</ui:UXML>

View File

@ -90,10 +90,16 @@ namespace YooAsset.Editor
public TableView()
{
_toolbar = new Toolbar();
this.Add(_toolbar);
this.style.flexShrink = 1f;
this.style.flexGrow = 1f;
// 定义标题栏
_toolbar = new Toolbar();
// 定义列表视图
_listView = new ListView();
_listView.style.flexShrink = 1f;
_listView.style.flexGrow = 1f;
_listView.makeItem = MakeListViewElement;
_listView.bindItem = BindListViewElement;
_listView.selectionType = SelectionType.Multiple;
@ -107,6 +113,7 @@ namespace YooAsset.Editor
_listView.onSelectionChanged += OnSelectionChanged;
#endif
this.Add(_toolbar);
this.Add(_listView);
}

View File

@ -40,7 +40,7 @@ namespace YooAsset
if (_bundle.Encrypted)
{
_downloadAssetBundleOp = new DownloadWebEncryptAssetBundleOperation(_fileSystem.DecryptionServices, _bundle, downloadParam);
_downloadAssetBundleOp = new DownloadWebEncryptAssetBundleOperation(true, _fileSystem.DecryptionServices, _bundle, downloadParam);
OperationSystem.StartOperation(_fileSystem.PackageName, _downloadAssetBundleOp);
}
else
@ -59,7 +59,7 @@ namespace YooAsset
if (_downloadAssetBundleOp.Status == EOperationStatus.Succeed)
{
var assetBundle = _downloadAssetBundleOp.Result;
if(assetBundle == null)
if (assetBundle == null)
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;

View File

@ -41,7 +41,7 @@ namespace YooAsset
if (_bundle.Encrypted)
{
_downloadAssetBundleOp = new DownloadWebEncryptAssetBundleOperation(_fileSystem.DecryptionServices, _bundle, downloadParam);
_downloadAssetBundleOp = new DownloadWebEncryptAssetBundleOperation(true, _fileSystem.DecryptionServices, _bundle, downloadParam);
OperationSystem.StartOperation(_fileSystem.PackageName, _downloadAssetBundleOp);
}
else

View File

@ -5,12 +5,14 @@ namespace YooAsset
{
internal class DownloadWebEncryptAssetBundleOperation : DownloadAssetBundleOperation
{
private readonly bool _checkTimeout;
private readonly IWebDecryptionServices _decryptionServices;
private DownloadHandlerBuffer _downloadhandler;
private ESteps _steps = ESteps.None;
internal DownloadWebEncryptAssetBundleOperation(IWebDecryptionServices decryptionServices, PackageBundle bundle, DownloadParam param) : base(bundle, param)
internal DownloadWebEncryptAssetBundleOperation(bool checkTimeout, IWebDecryptionServices decryptionServices, PackageBundle bundle, DownloadParam param) : base(bundle, param)
{
_checkTimeout = checkTimeout;
_decryptionServices = decryptionServices;
}
internal override void InternalOnStart()
@ -45,7 +47,8 @@ namespace YooAsset
Progress = DownloadProgress;
if (_webRequest.isDone == false)
{
CheckRequestTimeout();
if (_checkTimeout)
CheckRequestTimeout();
return;
}
@ -61,7 +64,17 @@ namespace YooAsset
return;
}
AssetBundle assetBundle = LoadEncryptedAssetBundle(_downloadhandler.data);
var fileData = _downloadhandler.data;
if (fileData == null || fileData.Length == 0)
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = $"The download handler data is null or empty !";
YooLogger.Error(Error);
return;
}
AssetBundle assetBundle = LoadEncryptedAssetBundle(fileData);
if (assetBundle == null)
{
_steps = ESteps.Done;

View File

@ -7,7 +7,7 @@ internal class TTFSDownloadFileOperation : DefaultDownloadFileOperation
{
private TiktokFileSystem _fileSystem;
private ESteps _steps = ESteps.None;
internal TTFSDownloadFileOperation(TiktokFileSystem fileSystem, PackageBundle bundle, DownloadParam param) : base(bundle, param)
{
_fileSystem = fileSystem;
@ -84,7 +84,7 @@ internal class TTFSDownloadFileOperation : DefaultDownloadFileOperation
private void CreateWebRequest()
{
//TODO : 抖音小游戏没有找到预下载方法
_webRequest = UnityWebRequestAssetBundle.GetAssetBundle(_requestURL);
_webRequest = UnityWebRequest.Get(_requestURL);
_webRequest.disposeDownloadHandlerOnDispose = true;
_webRequest.SendWebRequest();
}

View File

@ -41,7 +41,7 @@ internal class TTFSLoadBundleOperation : FSLoadBundleOperation
if (_bundle.Encrypted)
{
_downloadAssetBundleOp = new DownloadWebEncryptAssetBundleOperation(_fileSystem.DecryptionServices, _bundle, downloadParam);
_downloadAssetBundleOp = new DownloadWebEncryptAssetBundleOperation(false, _fileSystem.DecryptionServices, _bundle, downloadParam);
OperationSystem.StartOperation(_fileSystem.PackageName, _downloadAssetBundleOp);
}
else

View File

@ -92,7 +92,7 @@ internal class WXFSDownloadFileOperation : DefaultDownloadFileOperation
private void CreateWebRequest()
{
_webRequest = WXAssetBundle.GetAssetBundle(_requestURL);
_webRequest = UnityWebRequest.Get(_requestURL);
_webRequest.SetRequestHeader("wechatminigame-preload", "1");
_webRequest.disposeDownloadHandlerOnDispose = true;
_webRequest.SendWebRequest();

View File

@ -39,7 +39,7 @@ internal class WXFSLoadBundleOperation : FSLoadBundleOperation
if (_bundle.Encrypted)
{
_downloadAssetBundleOp = new DownloadWebEncryptAssetBundleOperation(_fileSystem.DecryptionServices, _bundle, downloadParam);
_downloadAssetBundleOp = new DownloadWebEncryptAssetBundleOperation(false, _fileSystem.DecryptionServices, _bundle, downloadParam);
OperationSystem.StartOperation(_fileSystem.PackageName, _downloadAssetBundleOp);
}
else