Add LateFixedUpdate event for C# scripts
This commit is contained in:
@@ -121,6 +121,19 @@ void SceneTicking::LateUpdateTickData::TickScripts(const Array<Script*>& scripts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SceneTicking::LateFixedUpdateTickData::LateFixedUpdateTickData()
|
||||||
|
: TickData(64)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void SceneTicking::LateFixedUpdateTickData::TickScripts(const Array<Script*>& scripts)
|
||||||
|
{
|
||||||
|
for (auto* script : scripts)
|
||||||
|
{
|
||||||
|
script->OnLateFixedUpdate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void SceneTicking::AddScript(Script* obj)
|
void SceneTicking::AddScript(Script* obj)
|
||||||
{
|
{
|
||||||
ASSERT_LOW_LAYER(obj && obj->GetParent() && obj->GetParent()->GetScene());
|
ASSERT_LOW_LAYER(obj && obj->GetParent() && obj->GetParent()->GetScene());
|
||||||
@@ -130,6 +143,9 @@ void SceneTicking::AddScript(Script* obj)
|
|||||||
Update.AddScript(obj);
|
Update.AddScript(obj);
|
||||||
if (obj->_tickLateUpdate)
|
if (obj->_tickLateUpdate)
|
||||||
LateUpdate.AddScript(obj);
|
LateUpdate.AddScript(obj);
|
||||||
|
if (obj->_tickLateFixedUpdate)
|
||||||
|
LateFixedUpdate.AddScript(obj);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SceneTicking::RemoveScript(Script* obj)
|
void SceneTicking::RemoveScript(Script* obj)
|
||||||
@@ -141,6 +157,8 @@ void SceneTicking::RemoveScript(Script* obj)
|
|||||||
Update.RemoveScript(obj);
|
Update.RemoveScript(obj);
|
||||||
if (obj->_tickLateUpdate)
|
if (obj->_tickLateUpdate)
|
||||||
LateUpdate.RemoveScript(obj);
|
LateUpdate.RemoveScript(obj);
|
||||||
|
if (obj->_tickLateFixedUpdate)
|
||||||
|
LateFixedUpdate.RemoveScript(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SceneTicking::Clear()
|
void SceneTicking::Clear()
|
||||||
@@ -148,4 +166,5 @@ void SceneTicking::Clear()
|
|||||||
FixedUpdate.Clear();
|
FixedUpdate.Clear();
|
||||||
Update.Clear();
|
Update.Clear();
|
||||||
LateUpdate.Clear();
|
LateUpdate.Clear();
|
||||||
|
LateFixedUpdate.Clear();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,6 +109,13 @@ public:
|
|||||||
void TickScripts(const Array<Script*>& scripts) override;
|
void TickScripts(const Array<Script*>& scripts) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class FLAXENGINE_API LateFixedUpdateTickData : public TickData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
LateFixedUpdateTickData();
|
||||||
|
void TickScripts(const Array<Script*>& scripts) override;
|
||||||
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adds the script to scene ticking system.
|
/// Adds the script to scene ticking system.
|
||||||
@@ -142,4 +149,9 @@ public:
|
|||||||
/// The late update tick function.
|
/// The late update tick function.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
LateUpdateTickData LateUpdate;
|
LateUpdateTickData LateUpdate;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The late fixed update tick function.
|
||||||
|
/// </summary>
|
||||||
|
LateFixedUpdateTickData LateFixedUpdate;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ Script::Script(const SpawnParams& params)
|
|||||||
, _tickFixedUpdate(false)
|
, _tickFixedUpdate(false)
|
||||||
, _tickUpdate(false)
|
, _tickUpdate(false)
|
||||||
, _tickLateUpdate(false)
|
, _tickLateUpdate(false)
|
||||||
|
, _tickLateFixedUpdate(false)
|
||||||
, _wasStartCalled(false)
|
, _wasStartCalled(false)
|
||||||
, _wasEnableCalled(false)
|
, _wasEnableCalled(false)
|
||||||
{
|
{
|
||||||
@@ -181,6 +182,7 @@ void Script::SetupType()
|
|||||||
_tickUpdate |= type.Script.ScriptVTable[8] != nullptr;
|
_tickUpdate |= type.Script.ScriptVTable[8] != nullptr;
|
||||||
_tickLateUpdate |= type.Script.ScriptVTable[9] != nullptr;
|
_tickLateUpdate |= type.Script.ScriptVTable[9] != nullptr;
|
||||||
_tickFixedUpdate |= type.Script.ScriptVTable[10] != nullptr;
|
_tickFixedUpdate |= type.Script.ScriptVTable[10] != nullptr;
|
||||||
|
_tickLateFixedUpdate |= type.Script.ScriptVTable[11] != nullptr;
|
||||||
}
|
}
|
||||||
typeHandle = type.GetBaseType();
|
typeHandle = type.GetBaseType();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ protected:
|
|||||||
int32 _tickFixedUpdate : 1;
|
int32 _tickFixedUpdate : 1;
|
||||||
int32 _tickUpdate : 1;
|
int32 _tickUpdate : 1;
|
||||||
int32 _tickLateUpdate : 1;
|
int32 _tickLateUpdate : 1;
|
||||||
|
int32 _tickLateFixedUpdate : 1;
|
||||||
int32 _wasStartCalled : 1;
|
int32 _wasStartCalled : 1;
|
||||||
int32 _wasEnableCalled : 1;
|
int32 _wasEnableCalled : 1;
|
||||||
#if USE_EDITOR
|
#if USE_EDITOR
|
||||||
|
|||||||
Reference in New Issue
Block a user