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);
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); }
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()); }