完善UI逻辑
This commit is contained in:
parent
78aa102238
commit
126a15e0b6
@ -62,6 +62,7 @@ namespace QFramework.Example
|
|||||||
protected override void OnInit(IUIData uiData = null)
|
protected override void OnInit(IUIData uiData = null)
|
||||||
{
|
{
|
||||||
TypeEventSystem.Global.Register<OnModuleQuit>(OnModuleQuithandler).UnRegisterWhenGameObjectDestroyed(this);
|
TypeEventSystem.Global.Register<OnModuleQuit>(OnModuleQuithandler).UnRegisterWhenGameObjectDestroyed(this);
|
||||||
|
StringEventSystem.Global.Register($"On{UIBody3DMenuTree.Name}Close", OnUIBody3DMenuTreeClose);
|
||||||
loader = ResLoader.Allocate();
|
loader = ResLoader.Allocate();
|
||||||
leftBgOriginalY = LeftBg.rectTransform.sizeDelta.y;
|
leftBgOriginalY = LeftBg.rectTransform.sizeDelta.y;
|
||||||
DragBtn.onValueChanged.AddListener(isOn =>
|
DragBtn.onValueChanged.AddListener(isOn =>
|
||||||
@ -99,7 +100,6 @@ namespace QFramework.Example
|
|||||||
|
|
||||||
MenuBtn.onClick.AddListener(() =>
|
MenuBtn.onClick.AddListener(() =>
|
||||||
{
|
{
|
||||||
//StringEventSystem.Global.Register($"On{UIBody3DMenuTree.Name}Close", OnUIBody3DMenuTreeClose);
|
|
||||||
UIKit.OpenPanelAsync<UIBody3DMenuTree>(canvasLevel: UILevel.PopUI, new UIBody3DMenuTreeData() { body = mData.body }).ToAction().StartGlobal();
|
UIKit.OpenPanelAsync<UIBody3DMenuTree>(canvasLevel: UILevel.PopUI, new UIBody3DMenuTreeData() { body = mData.body }).ToAction().StartGlobal();
|
||||||
//HideSelf(true);
|
//HideSelf(true);
|
||||||
});
|
});
|
||||||
@ -357,6 +357,11 @@ namespace QFramework.Example
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void OnUIBody3DMenuTreeClose()
|
||||||
|
{
|
||||||
|
OnShow();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 检查是否有相关UI
|
/// 检查是否有相关UI
|
||||||
/// 因为UI设计导致的臃肿代码
|
/// 因为UI设计导致的臃肿代码
|
||||||
@ -374,17 +379,7 @@ namespace QFramework.Example
|
|||||||
Hide();
|
Hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
//private void OnUIDrawClose()
|
|
||||||
//{
|
|
||||||
// StringEventSystem.Global.UnRegister($"On{UIDraw.Name}Close", OnUIDrawClose);
|
|
||||||
// HideSelf(false);
|
|
||||||
//}
|
|
||||||
|
|
||||||
//private void OnUIBody3DMenuTreeClose()
|
|
||||||
//{
|
|
||||||
// StringEventSystem.Global.UnRegister($"On{UIBody3DMenuTree.Name}Close", OnUIBody3DMenuTreeClose);
|
|
||||||
// HideSelf(false);
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
public void HideSelf(bool isTrue)
|
public void HideSelf(bool isTrue)
|
||||||
@ -431,6 +426,7 @@ namespace QFramework.Example
|
|||||||
obj.SetActive(body.isShow);
|
obj.SetActive(body.isShow);
|
||||||
bodyToggle.onValueChanged.AddListener(isOn =>
|
bodyToggle.onValueChanged.AddListener(isOn =>
|
||||||
{
|
{
|
||||||
|
SetAllChildren<Transform>(obj.transform, isOn);
|
||||||
obj.SetActive(isOn);
|
obj.SetActive(isOn);
|
||||||
});
|
});
|
||||||
var iconImg = bodyItem.transform.Find("Icon").GetComponent<Image>();
|
var iconImg = bodyItem.transform.Find("Icon").GetComponent<Image>();
|
||||||
@ -476,6 +472,19 @@ namespace QFramework.Example
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetAllChildren<T>(Transform parent, bool isOn)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < parent.childCount; i++)
|
||||||
|
{
|
||||||
|
Transform trans = parent.GetChild(i);
|
||||||
|
T t = trans.GetComponent<T>();
|
||||||
|
if (t != null)
|
||||||
|
{
|
||||||
|
trans.gameObject.SetActive(isOn);
|
||||||
|
}
|
||||||
|
SetAllChildren<T>(trans, isOn);
|
||||||
|
}
|
||||||
|
}
|
||||||
public void LoadIcon(string path, Body body, Image iconImg)
|
public void LoadIcon(string path, Body body, Image iconImg)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(body.Icon) == false)
|
if (string.IsNullOrEmpty(body.Icon) == false)
|
||||||
@ -501,6 +510,20 @@ namespace QFramework.Example
|
|||||||
|
|
||||||
protected override void OnShow()
|
protected override void OnShow()
|
||||||
{
|
{
|
||||||
|
if (mData != null && mData.body != null && mData.body.subBody != null)
|
||||||
|
{
|
||||||
|
int index = 0;
|
||||||
|
foreach (var item in mData.body.subBody)
|
||||||
|
{
|
||||||
|
Transform trans = BodyContent.GetChild(index);
|
||||||
|
index++;
|
||||||
|
if (item.Value.isBodyList == true)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
trans.GetComponent<Toggle>().isOn = Utility.FindObj(item.Value.Path).activeSelf;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnHide()
|
protected override void OnHide()
|
||||||
|
|||||||
@ -204,6 +204,7 @@ namespace QFramework.Example
|
|||||||
//DOTweenAnimation contentAnim;
|
//DOTweenAnimation contentAnim;
|
||||||
protected override void OnInit(IUIData uiData = null)
|
protected override void OnInit(IUIData uiData = null)
|
||||||
{
|
{
|
||||||
|
mData = uiData as UIBody3DMenuTreeData ?? new UIBody3DMenuTreeData();
|
||||||
TypeEventSystem.Global.Register<OnModuleQuit>(OnModuleQuithandler).UnRegisterWhenGameObjectDestroyed(this);
|
TypeEventSystem.Global.Register<OnModuleQuit>(OnModuleQuithandler).UnRegisterWhenGameObjectDestroyed(this);
|
||||||
//contentAnim = RootContent.GetComponent<DOTweenAnimation>();
|
//contentAnim = RootContent.GetComponent<DOTweenAnimation>();
|
||||||
// please add init code here
|
// please add init code here
|
||||||
@ -232,6 +233,7 @@ namespace QFramework.Example
|
|||||||
RefreshSearchContent(str);
|
RefreshSearchContent(str);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
BuildTreeUI(mData.body);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnModuleQuithandler(OnModuleQuit quit)
|
private void OnModuleQuithandler(OnModuleQuit quit)
|
||||||
@ -242,10 +244,19 @@ namespace QFramework.Example
|
|||||||
protected override void OnOpen(IUIData uiData = null)
|
protected override void OnOpen(IUIData uiData = null)
|
||||||
{
|
{
|
||||||
mData = uiData as UIBody3DMenuTreeData ?? new UIBody3DMenuTreeData();
|
mData = uiData as UIBody3DMenuTreeData ?? new UIBody3DMenuTreeData();
|
||||||
//contentAnim.DORestart();
|
foreach (var item in mData.body.subBody)
|
||||||
Content.RemoveAllChildren();
|
{
|
||||||
objBtnDataMap.Clear();
|
if (item.Value.isBodyList)
|
||||||
BuildTreeUI(mData.body);
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
GameObject obj = Utility.FindObj(item.Value.Path);
|
||||||
|
Button btn = Content.Find(item.Value.Name).Find("Content/Toggle/ObjContent/Obj").GetComponent<Button>();
|
||||||
|
if (obj.activeSelf && btn.GetComponentsInChildren<Transform>().Length <= 1)
|
||||||
|
{
|
||||||
|
btn.onClick.Invoke();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
private void BuildTreeUI(Body3D.Body data, int depth = 0, Transform parent = null)
|
private void BuildTreeUI(Body3D.Body data, int depth = 0, Transform parent = null)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user