修复了一些代码上的漏洞与预制体上的错误

This commit is contained in:
2025-08-31 19:42:33 +08:00
parent e432177af8
commit 2c784ff343
6 changed files with 638 additions and 11 deletions

View File

@@ -43,7 +43,7 @@ namespace Convention.WindowsUI.Variant
}
private void OnDestroy()
{
if (InspectorWindow.instance.GetTarget() == target)
if (InspectorWindow.instance != null && InspectorWindow.instance.GetTarget() == target)
{
InspectorWindow.instance.ClearWindow();
}
@@ -64,11 +64,13 @@ namespace Convention.WindowsUI.Variant
[Content]
public void OnFocusHierarchyItem()
{
if (target == null)
if (target != null)
{
throw new InvalidOperationException("target is null");
if (InspectorWindow.instance != null)
{
InspectorWindow.instance.SetTarget(target, this);
}
}
InspectorWindow.instance.SetTarget(target, this);
if (!IsEnableFocusWindow)
return;
if (FocusWindowIndictaor.instance != null)

View File

@@ -313,8 +313,12 @@ namespace Convention.WindowsUI.Variant
}
static IEnumerator Adjuster2(RectTransform rectTransform, ItemEntry parentEntry)
{
if (rectTransform == null)
yield break;
LayoutRebuilder.ForceRebuildLayoutImmediate(rectTransform);
yield return null;
if (rectTransform == null)
yield break;
RectTransformExtension.AdjustSizeToContainsChilds(rectTransform);
yield return null;
parentEntry.ForceRebuildLayoutImmediate();
@@ -364,6 +368,8 @@ namespace Convention.WindowsUI.Variant
ForceRebuildLayoutImmediate();
}
public bool IsRemovingChilds { get; private set; } = false;
public void Release()
{
if ((parentWindow == null && parentEntry == null) || childs == null || rootWindow == null)
@@ -376,21 +382,18 @@ namespace Convention.WindowsUI.Variant
ref_value.gameObject.SetActive(false);
Destroy(ref_value.gameObject);
}
IsRemovingChilds = true;
foreach (var item in childs)
{
item.Release();
}
IsRemovingChilds = false;
if (parentWindow != null)
parentWindow.m_Entrys.Remove(this);
else
else if (GetParent().IsRemovingChilds == false)
parentEntry.childs.Remove(this);
ref_value = null;
}
~ItemEntry()
{
Release();
}
}
public interface IItemEntry
{