From 57178b8a5b4b7f61b81ae2b129eaddf119ed944e Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Fri, 10 Feb 2023 14:43:24 +0100 Subject: [PATCH] Add dev-only name to spawned Particle System --- Source/Engine/Particles/ParticleSystem.cpp | 12 ++++++++++++ Source/Engine/Particles/ParticleSystem.h | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/Source/Engine/Particles/ParticleSystem.cpp b/Source/Engine/Particles/ParticleSystem.cpp index 7eaada32e..b04dfe0c0 100644 --- a/Source/Engine/Particles/ParticleSystem.cpp +++ b/Source/Engine/Particles/ParticleSystem.cpp @@ -39,6 +39,9 @@ void ParticleSystem::Init(ParticleEmitter* emitter, float duration, float fps) track.AsEmitter.Index = 0; track.AsEmitter.StartFrame = 0; track.AsEmitter.DurationFrames = DurationFrames; +#if !BUILD_RELEASE + _debugName = StringUtils::GetFileNameWithoutExtension(emitter->GetPath()); +#endif } } @@ -155,6 +158,9 @@ ParticleEffect* ParticleSystem::Spawn(Actor* parent, const Transform& transform, auto effect = New(); effect->SetTransform(transform); effect->ParticleSystem = this; +#if !BUILD_RELEASE + effect->SetName(_debugName); // Give usable name in development builds +#endif Level::SpawnActor(effect, parent); @@ -452,6 +458,9 @@ Asset::LoadResult ParticleSystem::load() return LoadResult::InvalidData; } +#if !BUILD_RELEASE + _debugName = StringUtils::GetFileNameWithoutExtension(GetPath()); +#endif return LoadResult::Ok; } @@ -463,6 +472,9 @@ void ParticleSystem::unload(bool isReloading) Emitters.Resize(0); EmittersParametersOverrides.SetCapacity(0); Tracks.Resize(0); +#if !BUILD_RELEASE + _debugName.Clear(); +#endif } AssetChunksFlag ParticleSystem::getChunksToPreload() const diff --git a/Source/Engine/Particles/ParticleSystem.h b/Source/Engine/Particles/ParticleSystem.h index 69212036f..48f944d2a 100644 --- a/Source/Engine/Particles/ParticleSystem.h +++ b/Source/Engine/Particles/ParticleSystem.h @@ -98,6 +98,11 @@ public: typedef Pair EmitterParameterOverrideKey; +private: +#if !BUILD_RELEASE + String _debugName; +#endif + public: /// /// The asset data version number. Used to sync the data with the instances state. Incremented each time asset gets loaded.