Esempio n. 1
0
    public void FillComponent(JsonHelperReader json, GameObject go)
    {
        json.Read(); // Drop StartObject
        string metaProp = json.ReadPropertyName();

        if (metaProp == JSONHelper.META.PROP)
        {
            Type componentType = json.ReadMetaObjectType();
            json.FillObject(go.GetComponent(componentType), componentType, null, true);
            return;
        }

        if (metaProp == JSONHelper.META.MARKER)
        {
            // Only meta currently allowed here is an external reference.
            // References back aren't allowed as one would need to read the same .json
            // and read / skip until the ref ID required is reached, then fill the component.
            // But doing even that only creates a shallow clone...
            // TODO do dat if it should be a shallow clone anyway.
            json.Read();    // Drop value
            using (JsonHelperReader ext = json.OpenMetaExternal(true)) {
                ext.Read(); // Go to Start
                FillComponent(ext, go);
            }
        }
    }