Skip to content

Commit

Permalink
Adding log warning if actor is parent of the target in the hierarchy …
Browse files Browse the repository at this point in the history
…+ adding IsDescendantOf to LuabActorBinder
  • Loading branch information
maxbrundev committed Oct 16, 2023
1 parent a5682de commit 5547c31
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ void OvCore::Scripting::LuaActorBinder::BindActor(sol::state & p_luaState)
"IsSelfActive", &Actor::IsSelfActive, // TODO: Add to doc
"IsActive", &Actor::IsActive,
"SetActive", &Actor::SetActive,
"IsDescendantOf", &Actor::IsDescendantOf,


/* Components Getters */
Expand Down
3 changes: 3 additions & 0 deletions Sources/Overload/OvEditor/src/OvEditor/Panels/Hierarchy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,10 @@ void OvEditor::Panels::Hierarchy::AddActorByInstance(OvCore::ECS::Actor & p_acto
textSelectable.AddPlugin<OvUI::Plugins::DDTarget<std::pair<OvCore::ECS::Actor*, OvUI::Widgets::Layout::TreeNode*>>>("Actor").DataReceivedEvent += [&p_actor, &textSelectable](std::pair<OvCore::ECS::Actor*, OvUI::Widgets::Layout::TreeNode*> p_element)
{
if (p_actor.IsDescendantOf(p_element.first))
{
OVLOG_WARNING("Cannot attach \"" + p_element.first->GetName() + "\" to \"" + p_actor.GetName() + "\" because it is a descendant of the latter.");
return;
}

p_element.first->SetParent(p_actor);
};
Expand Down

0 comments on commit 5547c31

Please sign in to comment.