From 78229d22a5fe07a7f06097248a70b6f1428e245a Mon Sep 17 00:00:00 2001 From: Lee Zak <69974259+leezak5555@users.noreply.github.com> Date: Mon, 19 Aug 2024 23:50:37 +0300 Subject: [PATCH] Unity Code stripping fix Keep the Default constructor for unity games with code stripping enabled --- src/codegen/languages/csharp.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/codegen/languages/csharp.ts b/src/codegen/languages/csharp.ts index 3dc19857..4809ab69 100644 --- a/src/codegen/languages/csharp.ts +++ b/src/codegen/languages/csharp.ts @@ -60,8 +60,15 @@ function generateClass(klass: Class, namespace: string) { using Colyseus.Schema; using Action = System.Action; +#if UNITY_5_3_OR_NEWER +using UnityEngine.Scripting; +#endif ${namespace ? `\nnamespace ${namespace} {` : ""} ${indent}public partial class ${klass.name} : ${klass.extends} { +#if UNITY_5_3_OR_NEWER +[Preserve] +#endif +public ${klass.name}() { } ${klass.properties.map((prop) => generateProperty(prop, indent)).join("\n\n")} ${indent}\t/*