Add improved default value detection for scripting object references in bindings generator

This commit is contained in:
Wojtek Figat
2024-08-12 15:34:39 +02:00
parent 63bee0c78d
commit 824d6701d8
2 changed files with 16 additions and 1 deletions

View File

@@ -102,8 +102,22 @@ namespace Flax.Build.Bindings
private static string GenerateCSharpDefaultValueNativeToManaged(BuildData buildData, string value, ApiTypeInfo caller, TypeInfo valueType = null, bool attribute = false, string managedType = null)
{
ApiTypeInfo apiType = null;
if (string.IsNullOrEmpty(value))
{
if (attribute && valueType != null && !valueType.IsArray)
{
//if (valueType.Type == "")
//ScriptingObjectReference
apiType = FindApiTypeInfo(buildData, valueType, caller);
// Object reference
if (apiType != null && apiType.IsScriptingObject)
return "null";
}
return null;
}
// Special case for Engine TEXT macro
if (value.StartsWith("TEXT(\"") && value.EndsWith("\")"))
@@ -150,7 +164,6 @@ namespace Flax.Build.Bindings
value = value.Replace("::", ".");
var dot = value.LastIndexOf('.');
ApiTypeInfo apiType = null;
if (dot != -1)
{
var type = new TypeInfo(value.Substring(0, dot));

View File

@@ -17,6 +17,8 @@ namespace Flax.Build.Bindings
"ScriptingObject",
"ManagedScriptingObject",
"PersistentScriptingObject",
"ScriptingObjectReference",
"AssetReference",
"BinaryAsset",
"SceneObject",
"Asset",