/// <summary>
/// dummy JSONObject class.
/// </summary>
public class JSONObject
{
public bool GetField(out bool field, string name, bool default_value)
{
field = default_value;
return true;
}
public bool GetField(out int field, string name, int default_value)
{
field = default_value;
return true;
}
}
/// <summary>
/// example Data class.
/// </summary>
public class Data
{
public int _int_value;
public bool _bool_value;
}
热更工程中调用:
// static method
public static void StaticFunTest()
{
UnityEngine.Debug.Log("!!! InstanceClass.StaticFunTest()");
try
{
JSONObject json = new JSONObject();
Data data = new Data();
json.GetField(out data._int_value, nameof(data._int_value), 0);
UnityEngine.Debug.Log("parse int value success.");
json.GetField(out data._bool_value, nameof(data._bool_value), false);
UnityEngine.Debug.Log("parse bool value success.");
}
catch (Exception e)
{
UnityEngine.Debug.LogError("parse data error.");
UnityEngine.Debug.LogException(e);
}
}
主工程类型定义:
热更工程中调用: