Unity Support
killop opened this issue · comments
hi ,i am a unity developer.
in unity il2cpp aot model,i generate cs file by fbs file , but i can not use RoslynSerializerGenerator , but without RoslynSerializerGenerator i can not register GeneratedSerializerWrapper to Serializer type cache, on my point FlatBufferSerializer.cs should have interface to register autogen cs class
1 no RoslynSerializerGenerator
2 interface for autogenerate Serializer
sorry for my poor english
You are attempting to use Runtime code generation in an environment that needs AOT support. You should be using the FlatSharp.Compiler
package instead of the FlatSharp
package.
https://github.com/jamescourtney/FlatSharp/wiki/Compiler/cfd1a8ac0d927ab7330cd153445c70d6d08154b6
Note that the wiki is in a state of flux right now as docs are updated for the upcoming v7 release of FlatSharp.
i think no one can use FlatSharp in unity without modify your soure code ,because Unity can not use RoslynSerializerGenerator
it is the point that Roslyn can only used in FlatSharp Compiler ,and should not be used in FlatSharp.Runtime
Roslyn is not used in FlatSharp.Runtime: https://github.com/jamescourtney/FlatSharp/blob/main/src/FlatSharp.Runtime/FlatSharp.Runtime.csproj
you are right that Roslyn is not used in FlatSharp.Runtime,but FlatSharp.Runtime.dll do not any interface exported your api ,just like FlatBufferSerializer in FlatSharp.dl
in short,how can i work with FlatSharp.generated,cs in unity without Roslyn
Take a look at the sample here: https://github.com/jamescourtney/FlatSharp/tree/main/samples/Example03-SchemaFiles2. The samples are intended to walk you through how to use FlatSharp. The short version is:
table MyTable (fs_serializer:"{option}") // option defined at: https://github.com/jamescourtney/FlatSharp/wiki/FBS-Annotations#fs_serializer
{
value : int;
}
var table = new MyTable();
byte[] buffer = new byte[MyTable.Serializer.GetMaxSize(table)];
int bytesWritten = MyTable.Serializer.Write(buffer, table);
var parsed = MyTable.Serializer.Parse(buffer);
fs_serializer
? i miss it,let me try again
holy shit ,it works, fantasy ,what a amzing attibutte "fs_serializer"
Thank you for your patience to answer
i will tell other people that it also work in unity ,nice code
Thank you :) I hope that FlatSharp works well for you. Please read the wiki and samples. There are lots more features that FlatSharp supports!