This commit is contained in:
ww-rm
2025-03-21 01:40:42 +08:00
parent 2535a9ebf9
commit 176e5db4d9
2 changed files with 21 additions and 2 deletions

View File

@@ -1093,6 +1093,25 @@ namespace SpineViewer.Spine.Implementations.SkeletonConverter
writer.WriteVarInt(name2idx[(string)name]);
}
public override JsonObject ReadJson(string jsonPath)
{
// replace 3.8.75 to another version to avoid detection in official runtime
var root = base.ReadJson(jsonPath);
var skeleton = root["skeleton"].AsObject();
var version = (string)skeleton["spine"];
if (version == "3.8.75") skeleton["spine"] = "3.8.76";
return root;
}
public override void WriteJson(JsonObject root, string jsonPath)
{
// replace 3.8.75 to another version to avoid detection in official runtime
var skeleton = root["skeleton"].AsObject();
var version = (string)skeleton["spine"];
if (version == "3.8.75") skeleton["spine"] = "3.8.76";
base.WriteJson(root, jsonPath);
}
public override JsonObject ToVersion(JsonObject root, Version version)
{
root = version switch

View File

@@ -92,7 +92,7 @@ namespace SpineViewer.Spine
/// <summary>
/// 读取 Json 对象
/// </summary>
public JsonObject ReadJson(string jsonPath)
public virtual JsonObject ReadJson(string jsonPath)
{
using var input = File.OpenRead(jsonPath);
if (JsonNode.Parse(input) is JsonObject root)
@@ -104,7 +104,7 @@ namespace SpineViewer.Spine
/// <summary>
/// 写入 Json 对象
/// </summary>
public void WriteJson(JsonObject root, string jsonPath)
public virtual void WriteJson(JsonObject root, string jsonPath)
{
using var output = File.Create(jsonPath);
using var writer = new Utf8JsonWriter(output, jsonWriterOptions);