Add LateFixedUpdate event for scripts

This commit is contained in:
2023-03-27 17:43:32 +03:00
parent aa64da9869
commit 558a7d99ff
7 changed files with 53 additions and 3 deletions

View File

@@ -108,6 +108,13 @@ public:
{
}
/// <summary>
/// Called every fixed framerate frame (after FixedUpdate) if object is enabled.
/// </summary>
API_FUNCTION(Attributes = "NoAnimate") virtual void OnLateFixedUpdate()
{
}
/// <summary>
/// Called during drawing debug shapes in editor. Use <see cref="DebugDraw"/> to draw debug shapes and other visualization.
/// </summary>

View File

@@ -46,6 +46,7 @@ public:
void Update() override;
void LateUpdate() override;
void FixedUpdate() override;
void LateFixedUpdate() override;
void Draw() override;
void BeforeExit() override;
void Dispose() override;
@@ -100,6 +101,7 @@ namespace
MMethod* _method_Update = nullptr;
MMethod* _method_LateUpdate = nullptr;
MMethod* _method_FixedUpdate = nullptr;
MMethod* _method_LateFixedUpdate = nullptr;
MMethod* _method_Draw = nullptr;
MMethod* _method_Exit = nullptr;
Array<BinaryModule*, InlinedAllocation<64>> _nonNativeModules;
@@ -210,6 +212,12 @@ void ScriptingService::FixedUpdate()
INVOKE_EVENT(FixedUpdate);
}
void ScriptingService::LateFixedUpdate()
{
PROFILE_CPU_NAMED("Scripting::LateFixedUpdate");
INVOKE_EVENT(LateFixedUpdate);
}
void ScriptingService::Draw()
{
PROFILE_CPU_NAMED("Scripting::Draw");

View File

@@ -80,17 +80,22 @@ namespace FlaxEngine
public static event Action Update;
/// <summary>
/// Occurs on scripting 'late' update.
/// Occurs on scripting late update.
/// </summary>
public static event Action LateUpdate;
/// <summary>
/// Occurs on scripting `fixed` update.
/// Occurs on scripting fixed update.
/// </summary>
public static event Action FixedUpdate;
/// <summary>
/// Occurs on scripting `draw` update. Called during frame rendering and can be used to invoke custom rendering with GPUDevice.
/// Occurs on scripting late fixed update.
/// </summary>
public static event Action LateFixedUpdate;
/// <summary>
/// Occurs on scripting draw update. Called during frame rendering and can be used to invoke custom rendering with GPUDevice.
/// </summary>
public static event Action Draw;
@@ -302,6 +307,11 @@ namespace FlaxEngine
FixedUpdate?.Invoke();
}
internal static void Internal_LateFixedUpdate()
{
LateFixedUpdate?.Invoke();
}
internal static void Internal_Draw()
{
Draw?.Invoke();