修正动态添加/异步添加ui组件的脏数据问题

修正动态添加/异步添加ui组件的脏数据问题
This commit is contained in:
ALEXTANG
2023-12-19 18:24:33 +08:00
parent 1423a3716a
commit 6107b41770
3 changed files with 22 additions and 1 deletions

View File

@@ -175,7 +175,15 @@ namespace TEngine
protected virtual void OnSetVisible(bool visible)
{
}
internal void SetUpdateDirty()
{
m_updateListValid = false;
if (Parent != null)
{
Parent.SetUpdateDirty();
}
}
#region FindChildComponent

View File

@@ -102,6 +102,11 @@ namespace TEngine
for (int i = 0; i < listChild.Count; i++)
{
var uiWidget = listChild[i];
if (uiWidget == null)
{
continue;
}
TProfiler.BeginSample(uiWidget.name);
var needValid = uiWidget.InternalUpdate();
@@ -208,6 +213,7 @@ namespace TEngine
RestChildCanvas(parentUI);
parent = parentUI;
Parent.ListChild.Add(this);
Parent.SetUpdateDirty();
ScriptGenerator();
BindMemberProperty();
RegisterEvent();
@@ -279,6 +285,8 @@ namespace TEngine
/// </summary>
internal void OnDestroyWidget()
{
Parent?.SetUpdateDirty();
RemoveAllUIEvent();
foreach (var uiChild in ListChild)

View File

@@ -318,6 +318,11 @@ namespace TEngine
{
var uiWidget = listChild[i];
if (uiWidget == null)
{
continue;
}
TProfiler.BeginSample(uiWidget.name);
var needValid = uiWidget.InternalUpdate();
TProfiler.EndSample();