feat(scripting): add mono csharp runtime foundation
This commit is contained in:
45
managed/GameScripts/HierarchyProbe.cs
Normal file
45
managed/GameScripts/HierarchyProbe.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using XCEngine;
|
||||
|
||||
namespace Gameplay
|
||||
{
|
||||
public sealed class HierarchyProbe : MonoBehaviour
|
||||
{
|
||||
public GameObject ReparentTarget;
|
||||
public string ObservedParentName = string.Empty;
|
||||
public string ObservedFirstChildName = string.Empty;
|
||||
public string ReparentedChildParentName = string.Empty;
|
||||
public bool ParentLookupSucceeded;
|
||||
public bool ChildLookupSucceeded;
|
||||
public int ObservedChildCount;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
Transform currentParent = transform.parent;
|
||||
ParentLookupSucceeded = currentParent != null;
|
||||
if (currentParent != null)
|
||||
{
|
||||
ObservedParentName = currentParent.gameObject.name;
|
||||
}
|
||||
|
||||
ObservedChildCount = transform.childCount;
|
||||
|
||||
Transform firstChild = transform.GetChild(0);
|
||||
ChildLookupSucceeded = firstChild != null;
|
||||
if (firstChild != null)
|
||||
{
|
||||
ObservedFirstChildName = firstChild.gameObject.name;
|
||||
|
||||
if (ReparentTarget != null)
|
||||
{
|
||||
firstChild.SetParent(ReparentTarget.transform, true);
|
||||
|
||||
Transform newParent = firstChild.parent;
|
||||
if (newParent != null)
|
||||
{
|
||||
ReparentedChildParentName = newParent.gameObject.name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user