Added Actor.GetPrefabRoot()

This commit is contained in:
Menotdan
2023-11-16 23:46:44 -05:00
parent bec878cc11
commit 3824b19c8b
2 changed files with 21 additions and 0 deletions
+15
View File
@@ -1339,6 +1339,21 @@ bool Actor::IsPrefabRoot() const
return _isPrefabRoot != 0;
}
Actor* Actor::GetPrefabRoot()
{
if (!this->HasPrefabLink())
{
return NULL;
}
Actor* result = this;
while (!result == NULL && !result->IsPrefabRoot())
{
result = result->GetParent();
}
return result;
}
Actor* Actor::FindActor(const StringView& name) const
{
Actor* result = nullptr;
+6
View File
@@ -739,6 +739,12 @@ public:
/// </summary>
API_PROPERTY() bool IsPrefabRoot() const;
/// <summary>
/// Gets the root of the prefab this actor is attached to.
/// </summary>
/// <returns>The root prefab object, or null if this actor is not a prefab.</returns>
API_FUNCTION() Actor* GetPrefabRoot();
public:
/// <summary>
/// Tries to find the actor with the given name in this actor hierarchy (checks this actor and all children hierarchy).