示例#1
0
        T GetExtension <T>(UniGLTF.glTFExtension extensions, UniJSON.Utf8String key, Func <ListTreeNode <JsonValue>, T> deserializer)
        {
            if (extensions is UniGLTF.glTFExtensionImport import)
            {
                foreach (var kv in import.ObjectItems())
                {
                    if (kv.Key.GetUtf8String() == key)
                    {
                        return(deserializer(kv.Value));
                    }
                }
            }

            return(default);
示例#2
0
        public static bool TryGet(UniGLTF.glTFExtension src, out VRMC_springBone extension)
        {
            if (src is UniGLTF.glTFExtensionImport extensions)
            {
                foreach (var kv in extensions.ObjectItems())
                {
                    if (kv.Key.GetUtf8String() == VRMC_springBone.ExtensionNameUtf8)
                    {
                        extension = Deserialize(kv.Value);
                        return(true);
                    }
                }
            }

            extension = default;
            return(false);
        }
示例#3
0
        public static void SerializeTo(ref UniGLTF.glTFExtension dst, VRMC_node_constraint extension)
        {
            if (dst is glTFExtensionImport)
            {
                throw new NotImplementedException();
            }

            if (!(dst is glTFExtensionExport extensions))
            {
                extensions = new glTFExtensionExport();
                dst = extensions;
            }

            var f = new JsonFormatter();
            Serialize(f, extension);
            extensions.Add(VRMC_node_constraint.ExtensionName, f.GetStoreBytes());
        }