EditorJsonUtility in Unity 5.5

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

Did you ever figure this out? I have the same problem.

Also wondering what’s up with this.
It doesn’t appear to be a bug, but can someone explain this behaviour?

What file ID could it possibly give for a scene object? I’ve never used it, but I would assume it would work more effectively on an asset instead. Try it on a ScriptableObject saved to the disk, or a prefab, and see if you have better luck there.

Unity 2017.3.0p1
I’ve got an object with script that links two Transforms. When I serialize it by script below I see this: “instanceID”: 0

private static string GetParameters(GameObject go)
{
string ans = "";

ans += EditorJsonUtility.ToJson(go,true); // GameObject
var components = go.GetComponents<Component>();

for (int i = 0, len = components.Length; i < len; i++)
{
var componentString = EditorJsonUtility.ToJson(components*, true);*
*ans = ans.Insert(ans.Length - 1, "," + componentString.Substring(1, componentString.Length - 2));*
*}*
*return ans;*
*}*
*```*

I also have this problem with EditorJsonUtility.ToJson.
tried on an asset file and only the first level (0) is given, while content of .asset file shows the sub-level content.

Same probleme here, what is going on ?