protected override void Serialize(SkinnedMeshRenderer obj, ref BinaryWriter writer, SerializerFactory serializer)
        {
            Stream stream = null;

            if (StoreInline)
            {
                stream = writer.BaseStream;
            }
            else
            {
                //TODO: write relative file path
                throw new NotImplementedException("Cannot store meshes in a separate file yet");
            }

            //store bones
            writer.Write(obj.bones.Length);
            foreach (var bone in obj.bones)
            {
                writer.Write(serializer.ReferenceMap[bone]);
            }


            writer.Write(obj.sharedMaterials.Length);
            foreach (var material in obj.sharedMaterials)
            {
                serializer.InternalSerialize(material, ref writer);
            }

            writer.Write((int)obj.quality);
            writer.Write(obj.localBounds);

            //store mesh
            UnityMeshFile.Write(stream, obj.sharedMesh, meshConfig);
        }
示例#2
0
    void Export()
    {
        var fileName = EditorUtility.SaveFilePanel("Export .unm file", "", _selection.name, "unm");

        if (string.IsNullOrEmpty(fileName))
        {
            return;
        }
        using (Stream stream = new FileStream(fileName, FileMode.OpenOrCreate))
        {
            UnityMeshFile.Write(stream, _selection);
        }
    }