From 5f4aee71b8c1de3a99e92b0ce8017fd9f07dcfb5 Mon Sep 17 00:00:00 2001 From: Mateusz Karbowiak <69864511+mtszkarbowiak@users.noreply.github.com> Date: Sat, 22 Jun 2024 15:14:02 +0200 Subject: [PATCH] Actor naming without string copy fix --- Source/Engine/Level/Actor.cpp | 9 +++++++++ Source/Engine/Level/Actor.h | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/Source/Engine/Level/Actor.cpp b/Source/Engine/Level/Actor.cpp index a30a929de..1cdfccd3b 100644 --- a/Source/Engine/Level/Actor.cpp +++ b/Source/Engine/Level/Actor.cpp @@ -543,6 +543,15 @@ void Actor::SetLayerRecursive(int32 layerIndex) OnLayerChanged(); } +void Actor::SetName(String&& value) +{ + if (_name == value) + return; + _name = MoveTemp(value); + if (GetScene()) + Level::callActorEvent(Level::ActorEventType::OnActorNameChanged, this, nullptr); +} + void Actor::SetName(const StringView& value) { if (_name == value) diff --git a/Source/Engine/Level/Actor.h b/Source/Engine/Level/Actor.h index dc77cdbee..fdf587b07 100644 --- a/Source/Engine/Level/Actor.h +++ b/Source/Engine/Level/Actor.h @@ -181,6 +181,11 @@ public: return _name; } + /// + /// Sets the actor name without copying the string. + /// + API_FUNCTION() void SetName(String&& value); + /// /// Sets the actor name. ///