Fix game ticking in editor during cut-scene rendering at edit time

This commit is contained in:
Wojtek Figat
2022-08-19 15:35:34 +02:00
parent a545520d6b
commit 20ebe3ac85
3 changed files with 16 additions and 5 deletions

View File

@@ -145,6 +145,7 @@ LevelService LevelServiceInstanceService;
CriticalSection Level::ScenesLock;
Array<Scene*> Level::Scenes;
bool Level::TickEnabled = true;
Delegate<Actor*> Level::ActorSpawned;
Delegate<Actor*> Level::ActorDeleted;
Delegate<Actor*, Actor*> Level::ActorParentChanged;
@@ -245,7 +246,7 @@ void LevelService::Update()
auto& scenes = Level::Scenes;
// Update all actors
if (!Time::GetGamePaused())
if (!Time::GetGamePaused() && Level::TickEnabled)
{
for (int32 i = 0; i < scenes.Count(); i++)
{
@@ -274,7 +275,7 @@ void LevelService::LateUpdate()
auto& scenes = Level::Scenes;
// Update all actors
if (!Time::GetGamePaused())
if (!Time::GetGamePaused() && Level::TickEnabled)
{
for (int32 i = 0; i < scenes.Count(); i++)
{
@@ -306,7 +307,7 @@ void LevelService::FixedUpdate()
auto& scenes = Level::Scenes;
// Update all actors
if (!Time::GetGamePaused())
if (!Time::GetGamePaused() && Level::TickEnabled)
{
for (int32 i = 0; i < scenes.Count(); i++)
{

View File

@@ -43,6 +43,11 @@ public:
/// </summary>
API_FIELD(ReadOnly) static Array<Scene*> Scenes;
/// <summary>
/// True if game objects (actors and scripts) can receive a tick during engine Update/LateUpdate/FixedUpdate events. Can be used to temporarily disable gameplay logic updating.
/// </summary>
API_FIELD() static bool TickEnabled;
public:
/// <summary>
/// Occurs when new actor gets spawned to the game.
@@ -104,7 +109,6 @@ public:
/// <summary>
/// Gets the scenes count.
/// </summary>
/// <returns>The scenes count.</returns>
API_PROPERTY() static int32 GetScenesCount()
{
return Scenes.Count();