chunk 1: core gameplay scripts scenes runtime assets
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class UltimateParentFinder : MonoBehaviour
|
||||
{
|
||||
public GameObject GetUltimateParent(GameObject child)
|
||||
{
|
||||
Transform currentTransform = child.transform;
|
||||
Transform ultimateParent = null;
|
||||
|
||||
while (currentTransform != null)
|
||||
{
|
||||
if (currentTransform.parent == null)
|
||||
{
|
||||
ultimateParent = currentTransform;
|
||||
break;
|
||||
}
|
||||
currentTransform = currentTransform.parent;
|
||||
}
|
||||
|
||||
if (ultimateParent != null && CharacterPrefabManager.Instance.IsValidCharacter(ultimateParent.gameObject))
|
||||
{
|
||||
return ultimateParent.gameObject;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user