Open MonoLogueChi opened 5 months ago
Do you have any plans to implement this feature?
I implemented part of it myself, can I PR to the warehouse? Is there anything I need to pay attention to when submitting a PR?
@MonoLogueChi Thanks so much. PR is welcome. I don't have a detailed contribution rule. If there is no problem, I would like to adopt it.
EDIT:
Ah, that reminds me, if we want to include Unity-dependent code, you can put it in /Unity
directory in /VYaml.Unity/Assets/VYaml/Runtime/.
It might cause problems with testing on the .net side. We will probably need to exclude the unity folder. https://github.com/hadashiA/VYaml/blob/master/VYaml/VYaml.csproj#L42
However, I can rework this after I merge your commits.
@hadashiA
Okay, I'll try not to break the original code and keep the style consistent.
The serialization I implemented is similar to the style of MessagePack-CSharp, that is
Color
Color32
-> [r,g,b,a]
Vector3
Vector3Int
-> [x,y,z]
This will not only make it easier to edit the configuration file, but will also be more efficient.
The parser that needs to be implemented will refer to Newtonsoft.Json-for-Unity.Converters
If I need to create a tool class and place some public code, where should I create it? The code is similar to this
internal static class Utils
{
public static void WriteFloatArrayWithFlowStyle(ref Utf8YamlEmitter emitter, IEnumerable<float> value,
YamlSerializationContext context)
{
emitter.BeginSequence(SequenceStyle.Flow);
foreach (var f in value) emitter.WriteFloat(f);
emitter.EndSequence();
}
public static void WriteByteArrayWithFlowStyle(ref Utf8YamlEmitter emitter, IEnumerable<byte> value,
YamlSerializationContext context)
{
emitter.BeginSequence(SequenceStyle.Flow);
foreach (var b in value) emitter.WriteInt32(b);
emitter.EndSequence();
}
public static void WriteIntArrayWithFlowStyle(ref Utf8YamlEmitter emitter, IEnumerable<int> value,
YamlSerializationContext context)
{
emitter.BeginSequence(SequenceStyle.Flow);
foreach (var i in value) emitter.WriteInt32(i);
emitter.EndSequence();
}
}
I have been sorting out the code recently and found that instead of merging it into VYaml, creating a VYaml.UnityResolvers project myself may be a better choice. The reasons are as follows
Thanks for the good work !
VYaml would like to focus on Unity. I would like to add similar functionality to the main repo using your code as a reference :)
I decided to port it to the main repo. #106
In some cases, I will need to serialize and deserialize Unity types, such as Vector3, Color, etc. Although I implemented part of it myself, I would like to have a UnityResolvers that contains commonly used Unity types and is automatically enabled when using Unity. Just like MessagePack-CSharp.