Optimize VariantType to use static type name in game or from non-reloadable assemblies

This avoids many dynamic memory allocations in Visual Scripts and Anim Graph.

#
This commit is contained in:
Wojtek Figat
2026-02-09 18:01:47 +01:00
parent bd300651ec
commit 7b7a92758f
10 changed files with 170 additions and 53 deletions

View File

@@ -502,6 +502,7 @@ bool Scripting::LoadBinaryModules(const String& path, const String& projectFolde
// C#
if (managedPath.HasChars() && !((ManagedBinaryModule*)module)->Assembly->IsLoaded())
{
(((ManagedBinaryModule*)module)->Assembly)->_canReload = module->CanReload;
if (((ManagedBinaryModule*)module)->Assembly->Load(managedPath, nativePath))
{
LOG(Error, "Failed to load C# assembly '{0}' for binary module {1}.", managedPath, name);
@@ -528,6 +529,7 @@ bool Scripting::Load()
#if USE_CSHARP
// Load C# core assembly
ManagedBinaryModule* corlib = GetBinaryModuleCorlib();
corlib->CanReload = false;
if (corlib->Assembly->LoadCorlib())
{
LOG(Error, "Failed to load corlib C# assembly.");
@@ -581,6 +583,8 @@ bool Scripting::Load()
LOG(Error, "Failed to load FlaxEngine C# assembly.");
return true;
}
flaxEngineModule->CanReload = false;
flaxEngineModule->Assembly->_canReload = false;
onEngineLoaded(flaxEngineModule->Assembly);
// Insert type aliases for vector types that don't exist in C++ but are just typedef (properly redirect them to actual types)