- [Core] fix formatting issue with Material preview.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AssetStudio
|
||||
{
|
||||
@@ -22,9 +23,13 @@ namespace AssetStudio
|
||||
|
||||
public class UnityPropertySheet
|
||||
{
|
||||
[JsonConverter(typeof(KVPConverter<UnityTexEnv>))]
|
||||
public List<KeyValuePair<string, UnityTexEnv>> m_TexEnvs;
|
||||
[JsonConverter(typeof(KVPConverter<int>))]
|
||||
public List<KeyValuePair<string, int>> m_Ints;
|
||||
[JsonConverter(typeof(KVPConverter<float>))]
|
||||
public List<KeyValuePair<string, float>> m_Floats;
|
||||
[JsonConverter(typeof(KVPConverter<Color>))]
|
||||
public List<KeyValuePair<string, Color>> m_Colors;
|
||||
|
||||
public UnityPropertySheet(ObjectReader reader)
|
||||
|
||||
35
AssetStudio/Helpers/KVPConverter.cs
Normal file
35
AssetStudio/Helpers/KVPConverter.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AssetStudio;
|
||||
public class KVPConverter<T> : JsonConverter
|
||||
{
|
||||
public KVPConverter() : base() { }
|
||||
|
||||
public override bool CanConvert(Type objectType)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
var list = (IList)value;
|
||||
writer.WriteStartObject();
|
||||
foreach (var val in list)
|
||||
{
|
||||
if (val is KeyValuePair<string, T> kvp)
|
||||
{
|
||||
writer.WritePropertyName(kvp.Key.ToString());
|
||||
serializer.Serialize(writer, kvp.Value);
|
||||
}
|
||||
}
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user