vrchat-community / UdonSharp

A compiler for compiling C# to Udon assembly
https://udonsharp.docs.vrchat.com
MIT License
477 stars 51 forks source link

[1.1.5] UdonSharp spams log with unserialized data errors at runtime when you have unserializable data #78

Open synergiance opened 2 years ago

synergiance commented 2 years ago

Describe the bug in detail: When using helper data structures in UdonSharp which aren't used at runtime, UdonSharp still complains every frame about not being able to serialize the data in that member. This is very spammy, and a singular error at the top of the log would be fine.

Provide steps/code to reproduce the bug: Define some sort of serializable struct:

[Serializable]
public struct MyStruct {
    public string myString;
    public int myInt;
}

Use it in your UdonBehaviour:

public class MyUdonSharpClass : UdonSharpBehaviour {
    public MyStruct myStructMember;
    public int myIntMember;
    // Other variables and methods
}

Expected behavior: UdonSharp complains only once about not being able to serialize MyStruct

Additional Information: I use structs in some of my UdonSharp behaviours to assist editor scripts, particularly nested arrays using reorderable lists. In earlier versions of U# I'd get one error about not being able to serialize the data, and I was relying on U# to just exclude that data from the UdonBehaviour and not being too fussy about it, since I replicate it over to Udon Compatible arrays in editor. Unfortunately these Udon compatible arrays are not reorderable list friendly and I require the nested structs arrays.

synergiance commented 1 year ago

I guess an attribute would be nice to tell UdonSharp to be quiet about any specific property, something like [NoUdonSerialize]