Hello,
according to the release notes of Unity 5.5
I wanted to try this as it sounds very useful for saving data from Editor scripts. However, for me, EditorJsonUtility doesn’t generate a fileID for object references, not even an instanceID as before.
Here are my test scripts:
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Test : MonoBehaviour
{
public GameObject reference;
public Transform component;
public string data;
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
[CustomEditor(typeof(Test))]
public class TestEditor : Editor
{
public Test Target
{
get
{
return (Test)target;
}
}
public override void OnInspectorGUI()
{
Debug.Log(EditorJsonUtility.ToJson(Target));
Debug.Log(JsonUtility.ToJson(Target));
base.OnInspectorGUI();
}
}
I get this from EditorJsonUtility.ToJson:
{"MonoBehaviour":{"m_Enabled":true,"m_EditorHideFlags":0,"m_Name":"","m_EditorClassIdentifier":"","reference":{"instanceID":0},"component":{"instanceID":0},"data":"Test"}}
→ instanceID is 0 ??? no fileID!
JsonUtility.ToJson is atleast generating instanceIDs…
{"reference":{"instanceID":9326},"component":{"instanceID":9336},"data":"Test"}
Is this broken or has anyone worked out how to use this “feature”?
Best,
SanityIsOverrated