Fix opening projects with PostFx material assigned in Graphics Settings

#1993
This commit is contained in:
Wojtek Figat
2024-02-21 20:21:45 +01:00
parent f3e6b74043
commit d7dbc0fbdc
4 changed files with 43 additions and 6 deletions

View File

@@ -347,6 +347,31 @@ struct MConverter<AssetReference<T>>
}
};
// TODO: use MarshalAs=Guid on SoftAssetReference to pass guid over bindings and not load asset in glue code
template<typename T>
class SoftAssetReference;
template<typename T>
struct MConverter<SoftAssetReference<T>>
{
void ToManagedArray(MArray* result, const Span<SoftAssetReference<T>>& data)
{
if (data.Length() == 0)
return;
MObject** objects = (MObject**)Allocator::Allocate(data.Length() * sizeof(MObject*));
for (int32 i = 0; i < data.Length(); i++)
objects[i] = data[i].GetManagedInstance();
MCore::GC::WriteArrayRef(result, Span<MObject*>(objects, data.Length()));
Allocator::Free(objects);
}
void ToNativeArray(Span<SoftAssetReference<T>>& result, const MArray* data)
{
MObject** dataPtr = MCore::Array::GetAddress<MObject*>(data);
for (int32 i = 0; i < result.Length(); i++)
result.Get()[i] = (T*)ScriptingObject::ToNative(dataPtr[i]);
}
};
// Converter for Array.
template<typename T>
struct MConverter<Array<T>>