Exemplo n.º 1
0
        public static void SaveSpringBoneToJson()
        {
            var path = EditorUtility.SaveFilePanel(
                "Save spring to json",
                null,
                "VRMSpring.json",
                "json");

            if (string.IsNullOrEmpty(path))
            {
                return;
            }

            var go     = Selection.activeObject as GameObject;
            var root   = go.transform;
            var nodes  = root.Traverse().Skip(1).ToList();
            var spring = new glTF_VRM_SecondaryAnimation();

            VRMSpringUtility.ExportSecondary(root, nodes,
                                             spring.colliderGroups.Add,
                                             spring.boneGroups.Add
                                             );

            var f = new UniJSON.JsonFormatter();

            VRM.VRMSerializer.Serialize_vrm_secondaryAnimation(f, spring);
            File.WriteAllBytes(path, f.GetStore().Bytes.ToArray());
        }
Exemplo n.º 2
0
        static void ExportMaterialExtension(Material m, glTFMaterial material)
        {
            // HDR Emission
            if (m.IsKeywordEnabled("_EMISSION") && m.HasProperty("_EmissionColor"))
            {
                var color = m.GetColor("_EmissionColor");
                if (color.maxColorComponent > 1)
                {
                    var extensions = new glTF_VCAST_materials_pbr();

                    extensions.emissiveFactor = new float[] { color.r, color.g, color.b };

                    var f = new UniJSON.JsonFormatter();
                    glTF_VCAST_materials_pbr_Serializer.Serialize(f, extensions);
                    glTFExtensionExport.GetOrCreate(ref material.extensions).Add(glTF_VCAST_materials_pbr.ExtensionName, f.GetStore().Bytes);
                }
            }
        }