【修复】修复code_cs_unity_editor_json无法加载多态数据的问题
parent
0e3782dd48
commit
856f30df5b
|
|
@ -6,6 +6,7 @@ using SimpleJSON;
|
||||||
name = x.name
|
name = x.name
|
||||||
parent_def_type = x.parent_def_type
|
parent_def_type = x.parent_def_type
|
||||||
parent = x.parent
|
parent = x.parent
|
||||||
|
hierarchy_fields = x.hierarchy_fields
|
||||||
fields = x.fields
|
fields = x.fields
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
|
@ -28,12 +29,10 @@ public {{x.cs_class_modifier}} partial class {{name}} : {{if parent_def_type}} {
|
||||||
{{~end~}}
|
{{~end~}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{{~if !x.is_abstract_type~}}
|
||||||
public override void LoadJson(SimpleJSON.JSONObject _json)
|
public override void LoadJson(SimpleJSON.JSONObject _json)
|
||||||
{
|
{
|
||||||
{{~if parent_def_type ~}}
|
{{~ for field in hierarchy_fields ~}}
|
||||||
base.LoadJson(_json);
|
|
||||||
{{~end~}}
|
|
||||||
{{~ for field in fields ~}}
|
|
||||||
{
|
{
|
||||||
var _fieldJson = _json["{{field.name}}"];
|
var _fieldJson = _json["{{field.name}}"];
|
||||||
if (_fieldJson != null)
|
if (_fieldJson != null)
|
||||||
|
|
@ -47,10 +46,10 @@ public {{x.cs_class_modifier}} partial class {{name}} : {{if parent_def_type}} {
|
||||||
|
|
||||||
public override void SaveJson(SimpleJSON.JSONObject _json)
|
public override void SaveJson(SimpleJSON.JSONObject _json)
|
||||||
{
|
{
|
||||||
{{~if parent_def_type ~}}
|
{{~if parent~}}
|
||||||
base.SaveJson(_json);
|
_json["{{x.json_type_name_key}}"] = "{{x.full_name}}";
|
||||||
{{~end~}}
|
{{~end~}}
|
||||||
{{~ for field in fields ~}}
|
{{~ for field in hierarchy_fields ~}}
|
||||||
{{~if field.ctype.is_nullable}}
|
{{~if field.ctype.is_nullable}}
|
||||||
if ({{field.convention_name}} != null)
|
if ({{field.convention_name}} != null)
|
||||||
{
|
{
|
||||||
|
|
@ -66,6 +65,7 @@ public {{x.cs_class_modifier}} partial class {{name}} : {{if parent_def_type}} {
|
||||||
{{~end~}}
|
{{~end~}}
|
||||||
{{~end~}}
|
{{~end~}}
|
||||||
}
|
}
|
||||||
|
{{~end~}}
|
||||||
|
|
||||||
public static {{name}} LoadJson{{name}}(SimpleJSON.JSONNode _json)
|
public static {{name}} LoadJson{{name}}(SimpleJSON.JSONNode _json)
|
||||||
{
|
{
|
||||||
|
|
@ -75,7 +75,10 @@ public {{x.cs_class_modifier}} partial class {{name}} : {{if parent_def_type}} {
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
{{~for child in x.hierarchy_not_abstract_children~}}
|
{{~for child in x.hierarchy_not_abstract_children~}}
|
||||||
case "{{cs_impl_data_type child x}}": obj = new {{child.full_name}}(); break;
|
{{~if child.namespace == x.namespace~}}
|
||||||
|
case "{{child.full_name}}":
|
||||||
|
{{~end~}}
|
||||||
|
case "{{cs_impl_data_type child x}}":obj = new {{child.full_name}}(); break;
|
||||||
{{~end~}}
|
{{~end~}}
|
||||||
default: throw new SerializationException();
|
default: throw new SerializationException();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue