06 优化加载资源包读取路径
This commit is contained in:
@@ -9,8 +9,6 @@ namespace Stary.Evo.UIFarme
|
||||
{
|
||||
public interface IBasePanel : IController
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 绑定这个面板的实例
|
||||
/// </summary>
|
||||
@@ -50,14 +48,14 @@ namespace Stary.Evo.UIFarme
|
||||
/// </summary>
|
||||
/// <param name="type">ui信息</param>
|
||||
/// <returns></returns>
|
||||
Task<GameObject> CreatePanel(string panelName);
|
||||
Task<GameObject> CreatePanel(string panelName, string packageName);
|
||||
|
||||
/// <summary>
|
||||
/// 销毁一个Ui对象
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
void DestoryUI();
|
||||
|
||||
|
||||
void SetPanelParent(Transform parent);
|
||||
}
|
||||
|
||||
@@ -79,21 +77,20 @@ namespace Stary.Evo.UIFarme
|
||||
/// <summary>
|
||||
/// 生成的父物体
|
||||
/// </summary>
|
||||
protected Transform panelParent{get; private set;}
|
||||
|
||||
protected Transform panelParent { get; private set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 缓存该面板所有的Button,Toggle,Slider,InputField,Dropdown,ScroolBar
|
||||
/// </summary>
|
||||
private Dictionary<string, Selectable> selectableDict;
|
||||
|
||||
protected CanvasGroup canvasGroup{get;private set;}
|
||||
|
||||
protected GameObject activePanel{get;private set;}
|
||||
protected CanvasGroup canvasGroup { get; private set; }
|
||||
|
||||
protected GameObject activePanel { get; private set; }
|
||||
|
||||
protected BasePanel()
|
||||
{
|
||||
|
||||
selectableDict = new Dictionary<string, Selectable>();
|
||||
}
|
||||
|
||||
@@ -148,32 +145,49 @@ namespace Stary.Evo.UIFarme
|
||||
}
|
||||
|
||||
|
||||
public async Task<GameObject> CreatePanel(string panelName)
|
||||
public async Task<GameObject> CreatePanel(string panelName, string packageName)
|
||||
{
|
||||
if (panelParent == null)
|
||||
{
|
||||
Debug.LogError($"UnityEvo:parent为空,{panelName}无法创建,进程已中断,请检查!!!!!");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
if (this.activePanel != null)
|
||||
{
|
||||
return activePanel.gameObject;
|
||||
}
|
||||
|
||||
var handle= YooAssets.LoadAssetAsync<GameObject>(panelName);
|
||||
AssetHandle handle = null;
|
||||
if (packageName == null)
|
||||
{
|
||||
handle = YooAssets.LoadAssetAsync<GameObject>(panelName);
|
||||
}
|
||||
else
|
||||
{
|
||||
var package= YooAssets.TryGetPackage(packageName);
|
||||
if (package == null)
|
||||
{
|
||||
handle = YooAssets.LoadAssetAsync<GameObject>(panelName);
|
||||
}
|
||||
else
|
||||
{
|
||||
handle = package.LoadAssetAsync<GameObject>(panelName);
|
||||
}
|
||||
}
|
||||
|
||||
await handle.Task;
|
||||
|
||||
activePanel = GameObject.Instantiate(handle.AssetObject as GameObject,panelParent);
|
||||
|
||||
activePanel = GameObject.Instantiate(handle.AssetObject as GameObject, panelParent);
|
||||
activePanel.name = this.GetType().Name;
|
||||
|
||||
|
||||
|
||||
|
||||
if (!activePanel.GetComponent<Canvas>())
|
||||
{
|
||||
Debug.LogError($"UnityEvo:panelParent上不存在Canvas组件,{panelName}无法正常运行,进程已中断,请检查!!!!!");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
return activePanel;
|
||||
}
|
||||
|
||||
@@ -204,6 +218,7 @@ namespace Stary.Evo.UIFarme
|
||||
{
|
||||
Debug.LogError($"{this.GetType()}---{name}:在selectableDict不存在");
|
||||
}
|
||||
|
||||
return t as T;
|
||||
}
|
||||
|
||||
@@ -212,6 +227,4 @@ namespace Stary.Evo.UIFarme
|
||||
return PanelSystem.GetArchitecture();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user