From cc511453f5c4026a064d589e68708043ac3e7331 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Mon, 21 Oct 2024 21:24:59 -0500 Subject: [PATCH] Handle c# code gen when C++ field has default value with style type `type{}` --- .../Flax.Build/Bindings/BindingsGenerator.CSharp.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.CSharp.cs b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.CSharp.cs index 17c92fe44..9642c8b02 100644 --- a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.CSharp.cs +++ b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.CSharp.cs @@ -153,6 +153,17 @@ namespace Flax.Build.Bindings case "false": return value; } + // Handle float{_} style type of default values + if (valueType != null && value.StartsWith($"{valueType.Type}") && value.EndsWith("}")) + { + value = value.Replace($"{valueType.Type}", "").Replace("{", "").Replace("}", "").Trim(); + if (string.IsNullOrEmpty(value)) + { + value = $"default({valueType.Type})"; + return value; + } + } + // Handle C++ bracket default values that are not arrays if (value.StartsWith("{") && value.EndsWith("}") && valueType != null && !valueType.IsArray && valueType.Type != "Array") {