Hey guys, I’m currently playing around with serializing existing C# classes to reuse in needle engine. I stumbled upon the mention of TypeSerializer in the docs but the example in the class comment does not help a lot. Is there any other source of wisdom for this?
Hi, what exactly are you trying to do that doesnt work already? Serializing/deserializing existing classes of whatever type should just work (if annotated with @serializable)
Hmm having a problem as I’ve declared MyClassTypeSerializer extends TypeSerialize before and now removed it: Uncaught SyntaxError: The requested module '/src/scripts/MyClass.ts' does not provide an export named 'MyClassTypeSerializer' (at register_types.ts:19:53)
Unfortunately, even a clean install does not get rid of it.
Ok, back to the original issue. Now I get warnings like this: vconsole.min.js:10 Please use lowercase for field: "ExtremeFoo" in MyClass foo!!! and even though it logs the value there for some reason (foo!!!) the value does not arrive at the property.
Haha, and on top of that I also have a name clash. My real-life property is string Context in C# so I’d have to declare context: string in TS but that’d overwrite/hide(?) Behaviour.context…
Luckily you’re using Newtonsoft.Json so I can use [JsonProperty("MyContext"] string Context and myContext: string
Where is that warning coming from? Note that you can declare it as a propery in typescript as well with just a setter (set ExtremeFoo(...). Also there are callbacks when you implement ISerializable on your class (see the methods available)