UI update 02
This commit is contained in:
@@ -147,6 +147,7 @@ namespace Bansonic
|
||||
{
|
||||
if (currentInstance != null && currentController != null)
|
||||
{
|
||||
ReparentIfNeeded();
|
||||
if (!currentInstance.activeInHierarchy)
|
||||
{
|
||||
currentInstance.SetActive(true);
|
||||
@@ -169,6 +170,7 @@ namespace Bansonic
|
||||
|
||||
currentInstance.name = prefab.name;
|
||||
currentController = currentInstance.GetComponent<itemGetPrefab>();
|
||||
ReparentIfNeeded();
|
||||
}
|
||||
|
||||
private static Transform ResolveParent()
|
||||
@@ -184,6 +186,11 @@ namespace Bansonic
|
||||
continue;
|
||||
}
|
||||
|
||||
if (IsTransitionCanvas(canvas))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (best == null || canvas.sortingOrder >= best.sortingOrder)
|
||||
{
|
||||
best = canvas;
|
||||
@@ -193,6 +200,52 @@ namespace Bansonic
|
||||
return best != null ? best.transform : null;
|
||||
}
|
||||
|
||||
private static void ReparentIfNeeded()
|
||||
{
|
||||
if (currentInstance == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Transform currentParent = currentInstance.transform.parent;
|
||||
bool needsReparent = currentParent == null || HasTransitionAncestor(currentParent);
|
||||
if (!needsReparent)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Transform targetParent = ResolveParent();
|
||||
if (targetParent == null || targetParent == currentParent)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
currentInstance.transform.SetParent(targetParent, false);
|
||||
currentInstance.transform.SetAsLastSibling();
|
||||
}
|
||||
|
||||
private static bool IsTransitionCanvas(Canvas canvas)
|
||||
{
|
||||
return canvas != null && HasTransitionAncestor(canvas.transform);
|
||||
}
|
||||
|
||||
private static bool HasTransitionAncestor(Transform transform)
|
||||
{
|
||||
Transform current = transform;
|
||||
while (current != null)
|
||||
{
|
||||
if (current.GetComponent<gTransBlack>() != null ||
|
||||
current.GetComponent<BansonicSceneTransitionOverlay>() != null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
current = current.parent;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static Color ResolveRarityColor(ItemRarity rarity)
|
||||
{
|
||||
ItemRarityColorConfigSO rarityConfig = GetRarityConfig();
|
||||
|
||||
Reference in New Issue
Block a user