HHWK0.1
This commit is contained in:
@@ -10,6 +10,34 @@ using UnityEngine;
|
||||
|
||||
namespace Assets.MyGame.Scripts.Net.WebResponses
|
||||
{
|
||||
|
||||
public static class FrameDataParser
|
||||
{
|
||||
public static T Parse<T>(object frameData) where T : class, new()
|
||||
{
|
||||
if (frameData == null) return null;
|
||||
|
||||
// 如果已经是目标类型,直接返回
|
||||
if (frameData is T typed) return typed;
|
||||
|
||||
// 如果是字符串,直接反序列化
|
||||
if (frameData is string str)
|
||||
return JsonConvert.DeserializeObject<T>(str);
|
||||
|
||||
// 如果是 JObject,轻量解析
|
||||
if (frameData is JObject jObj)
|
||||
return jObj.ToObject<T>();
|
||||
|
||||
// 兜底:调用 ToString 再反序列化
|
||||
return JsonConvert.DeserializeObject<T>(frameData.ToString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
[Serializable]
|
||||
public enum FrameDataType
|
||||
{
|
||||
@@ -65,6 +93,7 @@ namespace Assets.MyGame.Scripts.Net.WebResponses
|
||||
public class FrameData_ChangeAutoTarget : FrameData
|
||||
{
|
||||
public string targetGuid;
|
||||
public string targetPostName;
|
||||
}
|
||||
[Serializable]
|
||||
public class FrameData_RandomDieFish : FrameData
|
||||
|
||||
Reference in New Issue
Block a user