2019-05-11 04:33:54 +08:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
|
|
namespace XCharts
|
|
|
|
|
|
{
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 支持从json格式的字符串中导入数据
|
|
|
|
|
|
/// </summary>
|
2019-06-21 09:34:33 +08:00
|
|
|
|
public class JsonDataSupport : IJsonData, ISerializationCallbackReceiver
|
2019-05-11 04:33:54 +08:00
|
|
|
|
{
|
|
|
|
|
|
[SerializeField] protected string m_JsonData;
|
|
|
|
|
|
[SerializeField] protected bool m_DataFromJson;
|
|
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// json格式的字符串数据
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
2019-05-11 04:33:54 +08:00
|
|
|
|
public string jsonData { get { return m_JsonData; } set { m_JsonData = value; ParseJsonData(value); } }
|
|
|
|
|
|
|
|
|
|
|
|
public void OnAfterDeserialize()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (m_DataFromJson)
|
|
|
|
|
|
{
|
|
|
|
|
|
ParseJsonData(m_JsonData);
|
|
|
|
|
|
m_DataFromJson = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void OnBeforeSerialize()
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public virtual void ParseJsonData(string json)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new Exception("no support yet");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|