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