上传YomovSDK

This commit is contained in:
Sora丶kong
2026-03-03 03:15:46 +08:00
parent 9096da7e6c
commit eb97f31065
6477 changed files with 1932208 additions and 3 deletions

View File

@@ -0,0 +1,55 @@
using System;
using System.Collections;
using System.Diagnostics.CodeAnalysis;
using Newtonsoft.Json.UnityConverters.Helpers;
using Unity.Collections;
namespace Newtonsoft.Json.UnityConverters.NativeArray
{
public class NativeArrayConverter : JsonConverter
{
public override void WriteJson(JsonWriter writer, [AllowNull] object value, JsonSerializer serializer)
{
if (value is null)
{
writer.WriteNull();
return;
}
var enumerable = (IEnumerable)value;
writer.WriteStartArray();
foreach (object item in enumerable)
{
serializer.Serialize(writer, item);
}
writer.WriteEndArray();
}
[return: MaybeNull]
public override object ReadJson(JsonReader reader, Type objectType, [AllowNull] object existingValue, JsonSerializer serializer)
{
if (reader.TokenType == JsonToken.Null)
{
return null;
}
throw reader.CreateSerializationException(
"Deserializing NativeArray<> and NativeSlice<> is disabled to not cause accidental memory leaks. Use regular List<> or array types instead in your JSON models. Due to technical limitations, we cannot even populate existing NativeArray<> or NativeSlice<> values. You simply have to use other collection types."
);
}
public override bool CanConvert(Type objectType)
{
if (objectType.IsGenericType)
{
Type genericTypeDefinition = objectType.GetGenericTypeDefinition();
return genericTypeDefinition == typeof(NativeArray<>)
|| genericTypeDefinition == typeof(NativeSlice<>);
}
else
{
return false;
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 73a8e6a37cf4d6b42891ee7cbab4ce01
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: