Merge branch 'getprefabroot' of https://github.com/Menotdan/FlaxEngine into Menotdan-getprefabroot

This commit is contained in:
Wojtek Figat
2024-02-18 20:13:30 +01:00
2 changed files with 21 additions and 0 deletions

View File

@@ -1356,6 +1356,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;

View File

@@ -737,6 +737,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).