From 383c334675f8f2e7c780efab2412cd440efeca32 Mon Sep 17 00:00:00 2001
From: stary <834207172@qq.com>
Date: Fri, 15 May 2026 13:43:34 +0800
Subject: [PATCH] 111
---
.../00.StaryEvo/Runtime/Tool/PanelSystem.meta | 8 +++
.../Runtime/Tool/PanelSystem/AssetLoader.meta | 8 +++
.../PanelSystem/AssetLoader/IAssetLoader.cs | 25 ++++++++
.../AssetLoader/IAssetLoader.cs.meta | 11 ++++
.../AssetLoader/ResourcesAssetLoader.cs | 47 +++++++++++++++
.../AssetLoader/ResourcesAssetLoader.cs.meta | 11 ++++
.../Runtime/Tool}/PanelSystem/Base.meta | 0
.../Tool}/PanelSystem/Base/BasePanel.cs | 41 ++++++-------
.../Tool}/PanelSystem/Base/BasePanel.cs.meta | 0
.../Tool}/PanelSystem/Base/BaseRenderPanel.cs | 40 ++++++-------
.../PanelSystem/Base/BaseRenderPanel.cs.meta | 0
.../Runtime/Tool}/PanelSystem/Manager.meta | 0
.../Tool}/PanelSystem/Manager/PanelSystem.cs | 21 +++++--
.../PanelSystem/Manager/PanelSystem.cs.meta | 0
.../Manager/SpriteRendererSystem.cs | 16 ++++-
.../Manager/SpriteRendererSystem.cs.meta | 0
.../Runtime/Tool}/PanelSystem/UITool.meta | 0
.../Tool}/PanelSystem/UITool/UITool.cs | 0
.../Tool}/PanelSystem/UITool/UITool.cs.meta | 0
.../Runtime/com.stary.evo.runtime.asmdef | 3 +-
Assets/00.StaryEvo/package.json | 2 +-
.../Runtime/Tools/PanelSystem.meta | 9 +--
.../Tools/PanelSystem/YooAssetLoader.cs | 58 +++++++++++++++++++
.../Tools/PanelSystem/YooAssetLoader.cs.meta | 11 ++++
Assets/00.StaryEvoTools/package.json | 2 +-
25 files changed, 253 insertions(+), 60 deletions(-)
create mode 100644 Assets/00.StaryEvo/Runtime/Tool/PanelSystem.meta
create mode 100644 Assets/00.StaryEvo/Runtime/Tool/PanelSystem/AssetLoader.meta
create mode 100644 Assets/00.StaryEvo/Runtime/Tool/PanelSystem/AssetLoader/IAssetLoader.cs
create mode 100644 Assets/00.StaryEvo/Runtime/Tool/PanelSystem/AssetLoader/IAssetLoader.cs.meta
create mode 100644 Assets/00.StaryEvo/Runtime/Tool/PanelSystem/AssetLoader/ResourcesAssetLoader.cs
create mode 100644 Assets/00.StaryEvo/Runtime/Tool/PanelSystem/AssetLoader/ResourcesAssetLoader.cs.meta
rename Assets/{00.StaryEvoTools/Runtime/Tools => 00.StaryEvo/Runtime/Tool}/PanelSystem/Base.meta (100%)
rename Assets/{00.StaryEvoTools/Runtime/Tools => 00.StaryEvo/Runtime/Tool}/PanelSystem/Base/BasePanel.cs (91%)
rename Assets/{00.StaryEvoTools/Runtime/Tools => 00.StaryEvo/Runtime/Tool}/PanelSystem/Base/BasePanel.cs.meta (100%)
rename Assets/{00.StaryEvoTools/Runtime/Tools => 00.StaryEvo/Runtime/Tool}/PanelSystem/Base/BaseRenderPanel.cs (90%)
rename Assets/{00.StaryEvoTools/Runtime/Tools => 00.StaryEvo/Runtime/Tool}/PanelSystem/Base/BaseRenderPanel.cs.meta (100%)
rename Assets/{00.StaryEvoTools/Runtime/Tools => 00.StaryEvo/Runtime/Tool}/PanelSystem/Manager.meta (100%)
rename Assets/{00.StaryEvoTools/Runtime/Tools => 00.StaryEvo/Runtime/Tool}/PanelSystem/Manager/PanelSystem.cs (94%)
rename Assets/{00.StaryEvoTools/Runtime/Tools => 00.StaryEvo/Runtime/Tool}/PanelSystem/Manager/PanelSystem.cs.meta (100%)
rename Assets/{00.StaryEvoTools/Runtime/Tools => 00.StaryEvo/Runtime/Tool}/PanelSystem/Manager/SpriteRendererSystem.cs (96%)
rename Assets/{00.StaryEvoTools/Runtime/Tools => 00.StaryEvo/Runtime/Tool}/PanelSystem/Manager/SpriteRendererSystem.cs.meta (100%)
rename Assets/{00.StaryEvoTools/Runtime/Tools => 00.StaryEvo/Runtime/Tool}/PanelSystem/UITool.meta (100%)
rename Assets/{00.StaryEvoTools/Runtime/Tools => 00.StaryEvo/Runtime/Tool}/PanelSystem/UITool/UITool.cs (100%)
rename Assets/{00.StaryEvoTools/Runtime/Tools => 00.StaryEvo/Runtime/Tool}/PanelSystem/UITool/UITool.cs.meta (100%)
create mode 100644 Assets/00.StaryEvoTools/Runtime/Tools/PanelSystem/YooAssetLoader.cs
create mode 100644 Assets/00.StaryEvoTools/Runtime/Tools/PanelSystem/YooAssetLoader.cs.meta
diff --git a/Assets/00.StaryEvo/Runtime/Tool/PanelSystem.meta b/Assets/00.StaryEvo/Runtime/Tool/PanelSystem.meta
new file mode 100644
index 0000000..1f1ea2a
--- /dev/null
+++ b/Assets/00.StaryEvo/Runtime/Tool/PanelSystem.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: bd3da5461163cd64ab3441b4a74898b9
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/00.StaryEvo/Runtime/Tool/PanelSystem/AssetLoader.meta b/Assets/00.StaryEvo/Runtime/Tool/PanelSystem/AssetLoader.meta
new file mode 100644
index 0000000..fe25493
--- /dev/null
+++ b/Assets/00.StaryEvo/Runtime/Tool/PanelSystem/AssetLoader.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 4d89fa7f5efc28243a1c998e29f158a6
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/00.StaryEvo/Runtime/Tool/PanelSystem/AssetLoader/IAssetLoader.cs b/Assets/00.StaryEvo/Runtime/Tool/PanelSystem/AssetLoader/IAssetLoader.cs
new file mode 100644
index 0000000..3747fbf
--- /dev/null
+++ b/Assets/00.StaryEvo/Runtime/Tool/PanelSystem/AssetLoader/IAssetLoader.cs
@@ -0,0 +1,25 @@
+using System.Threading.Tasks;
+using UnityEngine;
+
+namespace Stary.Evo.UIFarme
+{
+ ///
+ /// 资源加载策略接口,用于抽象不同的资源加载方式(如YooAsset、Resources等)
+ ///
+ public interface IAssetLoader
+ {
+ ///
+ /// 异步加载GameObject资源
+ ///
+ /// 资源路径
+ /// YooAsset包名,Resources模式可忽略
+ /// 加载到的GameObject资源(非实例,是原始Prefab)
+ Task LoadGameObjectAsync(string assetPath, string packageName = null);
+
+ ///
+ /// 卸载指定资源,释放底层资源句柄
+ ///
+ /// 资源路径
+ void UnloadAsset(string assetPath);
+ }
+}
diff --git a/Assets/00.StaryEvo/Runtime/Tool/PanelSystem/AssetLoader/IAssetLoader.cs.meta b/Assets/00.StaryEvo/Runtime/Tool/PanelSystem/AssetLoader/IAssetLoader.cs.meta
new file mode 100644
index 0000000..62a9fe6
--- /dev/null
+++ b/Assets/00.StaryEvo/Runtime/Tool/PanelSystem/AssetLoader/IAssetLoader.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: eee0c2ac899cda04d8ec4a2bb7687195
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/00.StaryEvo/Runtime/Tool/PanelSystem/AssetLoader/ResourcesAssetLoader.cs b/Assets/00.StaryEvo/Runtime/Tool/PanelSystem/AssetLoader/ResourcesAssetLoader.cs
new file mode 100644
index 0000000..40dd3ad
--- /dev/null
+++ b/Assets/00.StaryEvo/Runtime/Tool/PanelSystem/AssetLoader/ResourcesAssetLoader.cs
@@ -0,0 +1,47 @@
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using UnityEngine;
+
+namespace Stary.Evo.UIFarme
+{
+ ///
+ /// 基于Resources的资源加载实现
+ ///
+ public class ResourcesAssetLoader : IAssetLoader
+ {
+ private readonly Dictionary _assetCache = new Dictionary();
+
+ ///
+ /// 通过Resources异步加载GameObject资源
+ ///
+ public async Task LoadGameObjectAsync(string assetPath, string packageName = null)
+ {
+ // Resources模式下忽略packageName
+ var request = Resources.LoadAsync(assetPath);
+ while (!request.isDone)
+ {
+ await Task.Yield();
+ }
+
+ var asset = request.asset as GameObject;
+ if (asset != null)
+ {
+ _assetCache[assetPath] = asset;
+ }
+
+ return asset;
+ }
+
+ ///
+ /// 释放Resources加载的资源
+ ///
+ public void UnloadAsset(string assetPath)
+ {
+ if (_assetCache.TryGetValue(assetPath, out Object asset) && asset != null)
+ {
+ Resources.UnloadAsset(asset);
+ _assetCache.Remove(assetPath);
+ }
+ }
+ }
+}
diff --git a/Assets/00.StaryEvo/Runtime/Tool/PanelSystem/AssetLoader/ResourcesAssetLoader.cs.meta b/Assets/00.StaryEvo/Runtime/Tool/PanelSystem/AssetLoader/ResourcesAssetLoader.cs.meta
new file mode 100644
index 0000000..76225b8
--- /dev/null
+++ b/Assets/00.StaryEvo/Runtime/Tool/PanelSystem/AssetLoader/ResourcesAssetLoader.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 21c72a85d6a282940bb331dfd1c926fd
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/00.StaryEvoTools/Runtime/Tools/PanelSystem/Base.meta b/Assets/00.StaryEvo/Runtime/Tool/PanelSystem/Base.meta
similarity index 100%
rename from Assets/00.StaryEvoTools/Runtime/Tools/PanelSystem/Base.meta
rename to Assets/00.StaryEvo/Runtime/Tool/PanelSystem/Base.meta
diff --git a/Assets/00.StaryEvoTools/Runtime/Tools/PanelSystem/Base/BasePanel.cs b/Assets/00.StaryEvo/Runtime/Tool/PanelSystem/Base/BasePanel.cs
similarity index 91%
rename from Assets/00.StaryEvoTools/Runtime/Tools/PanelSystem/Base/BasePanel.cs
rename to Assets/00.StaryEvo/Runtime/Tool/PanelSystem/Base/BasePanel.cs
index 6724691..7d098ab 100644
--- a/Assets/00.StaryEvoTools/Runtime/Tools/PanelSystem/Base/BasePanel.cs
+++ b/Assets/00.StaryEvo/Runtime/Tool/PanelSystem/Base/BasePanel.cs
@@ -1,10 +1,9 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using DG.Tweening;
using UnityEngine;
using UnityEngine.UI;
-using YooAsset;
namespace Stary.Evo.UIFarme
{
@@ -104,6 +103,11 @@ namespace Stary.Evo.UIFarme
protected GameObject activePanel { get; private set; }
+ ///
+ /// 记录当前面板的资源路径,用于释放资源句柄
+ ///
+ private string _assetPath;
+
protected BasePanel()
{
selectableDict = new Dictionary();
@@ -199,32 +203,18 @@ namespace Stary.Evo.UIFarme
{
return activePanel.gameObject;
}
- AssetHandle handle = null;
- if (packageName == null)
+
+ _assetPath = panelName;
+ var asset = await PanelSystem.AssetLoader.LoadGameObjectAsync(panelName, packageName);
+ if (asset == null)
{
- handle = YooAssets.LoadAssetAsync(panelName);
- }
- else
- {
- var package = YooAssets.TryGetPackage(packageName);
- if (package == null)
- {
- handle = YooAssets.LoadAssetAsync(panelName);
- }
- else
- {
- handle = package.LoadAssetAsync(panelName);
- }
+ Debug.LogError($"UnityEvo:资源加载失败,{panelName}未找到!");
+ return null;
}
- await handle.Task;
-
- activePanel = GameObject.Instantiate(handle.AssetObject as GameObject, panelParent);
-
-
+ activePanel = GameObject.Instantiate(asset, panelParent);
activePanel.name = this.GetType().Name;
-
if (!activePanel.GetComponentInChildren