mirror of
https://github.com/aelurum/AssetStudio.git
synced 2025-07-14 02:54:16 -04:00
Add option to export Live2D Cubism models
This commit is contained in:
35
AssetStudioUtility/CubismLive2DExtractor/MyJsonConverter.cs
Normal file
35
AssetStudioUtility/CubismLive2DExtractor/MyJsonConverter.cs
Normal file
@ -0,0 +1,35 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace CubismLive2DExtractor
|
||||
{
|
||||
public class MyJsonConverter : JsonConverter
|
||||
{
|
||||
public override bool CanConvert(Type objectType)
|
||||
{
|
||||
return objectType == typeof(List<float>);
|
||||
}
|
||||
|
||||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
||||
{
|
||||
writer.WriteStartArray();
|
||||
Convert(writer, (List<float>)value);
|
||||
writer.WriteEndArray();
|
||||
}
|
||||
|
||||
private void Convert(JsonWriter writer, List<float> array)
|
||||
{
|
||||
foreach (var n in array)
|
||||
{
|
||||
var v = n.ToString("0.###", System.Globalization.CultureInfo.InvariantCulture);
|
||||
writer.WriteRawValue(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user