Every Unity.Mathematics using, alias and qualified name under Assets\Scripts and tools now names CultMath. The nine `using static ...noise;` lines are gone: snoise lives on CultMath's math. UnityExtensions loses float4.ToColor and Color.ToFloat4, which duplicate the bridge's ToColor and ToCultMath; the float3 colour pair stays because the bridge has none. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
37 lines
1.1 KiB
C#
37 lines
1.1 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using MessagePack;
|
|
using MessagePack.ReactivePropertyExtension;
|
|
using MessagePack.Resolvers;
|
|
using Newtonsoft.Json;
|
|
|
|
public static class RegisterResolver
|
|
{
|
|
private static bool registered = false;
|
|
public static void Register()
|
|
{
|
|
if (registered) return;
|
|
|
|
// Set extensions to default resolver.
|
|
var resolver = CompositeResolver.Create(
|
|
MathResolver.Instance,
|
|
TypeResolver.Instance,
|
|
NativeGuidResolver.Instance,
|
|
StandardResolver.Instance,
|
|
ReactivePropertyResolver.Instance
|
|
);
|
|
var options = MessagePackSerializerOptions.Standard.WithResolver(resolver);
|
|
MessagePackSerializer.DefaultOptions = options;
|
|
|
|
// Add CultMath serialization support to Newtonsoft JSON
|
|
JsonConvert.DefaultSettings = () => new JsonSerializerSettings
|
|
{
|
|
Converters = new List<JsonConverter>
|
|
{
|
|
new MathJsonConverter()
|
|
}
|
|
};
|
|
|
|
registered = true;
|
|
}
|
|
}
|