public override Extension Deserialize(GLTFRoot root, JProperty extensionToken)
        {
            var extension = new Sein_nodeExtension();

            if (extensionToken != null)
            {
                extension.selfType     = (int)extensionToken.Value["selfType"] == 1 ? ESeinNodeType.Component : ESeinNodeType.Actor;
                extension.childrenType = (int)extensionToken.Value["childrenType"] == 1 ? ESeinNodeType.Component : ESeinNodeType.Actor;
                extension.className    = (string)extensionToken.Value["className"];
                extension.tag          = (string)extensionToken.Value["tag"];
                if (extensionToken.Value["layer"] != null)
                {
                    extension.layer = (int)extensionToken.Value["layer"];
                }
                extension.persistent       = (bool)extensionToken.Value["persistent"];
                extension.updateOnEverTick = (bool)extensionToken.Value["updateOnEverTick"];
                if (extensionToken.Value["isStatic"] != null)
                {
                    extension.isStatic = (bool)extensionToken.Value["isStatic"];
                }
                extension.skipThisNode = (bool)extensionToken.Value["skipThisNode"];
            }

            return(extension);
        }
Beispiel #2
0
    public virtual JObject Serialize(SeinJS.ExporterEntry entry, SeinJS.Sein_nodeExtension extension)
    {
        var type      = GetType();
        var className = type.FullName.Replace("SeinNodeClass_", "");

        extension.className = string.IsNullOrEmpty(className) ? extension.className : className;
        var result = new JObject();

        if (type.GetField("options") == null)
        {
            return(result);
        }

        var initOptions = type.GetField("options").GetValue(this);

        foreach (var pair in initOptions.GetType().GetFields())
        {
            var option = SerializeValue(entry, pair.GetValue(initOptions));
            result.Add(pair.Name, new JObject(
                           new JProperty("type", option.type),
                           new JProperty("value", option.value)
                           ));
        }

        return(result);
    }
Beispiel #3
0
        public override void Serialize(ExporterEntry entry, Dictionary <string, Extension> extensions, UnityEngine.Object component = null, object options = null)
        {
            var extension = new Sein_nodeExtension();
            var node      = component as SeinNode;

            extension.selfType              = node.selfType;
            extension.childrenType          = node.childrenType;
            extension.className             = node.className;
            extension.tag                   = node.tag;
            extension.layer                 = node.layer;
            extension.persistent            = node.persistent;
            extension.emitComponentsDestroy = node.emitComponentsDestroy;
            extension.updateOnEverTick      = node.updateOnEverTick;
            extension.isStatic              = node.isStatic;
            extension.skipThisNode          = node.skipThisNode;

            var com = node.GetComponent <SeinNodeClass>();

            if (com != null)
            {
                extension.initOptions = com.Serialize(entry, extension);
            }

            AddExtension(extensions, extension);
        }