Exemplo n.º 1
0
        private void SaveAt(MuseReciever reciever, string path)
        {
            if (string.IsNullOrEmpty(path))
            {
                return;
            }
            if (reciever.Tokens == 0)
            {
                return;
            }

            MidiAsset asset = MidiAsset.CreateInstance <MidiAsset>();

            asset.MidiFile = MuseDecoder.DecodeMuseEncoding(reciever.EncodedMidi);

            //int i = 1;
            //string org = Path.GetDirectoryName(path) + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(path);
            //string ext = Path.GetExtension(path);
            //while (File.Exists(path)) {
            //    path = org + i + ext;
            //    i++;
            //        }
            if (File.Exists(path))
            {
                File.Delete(path);
            }
            AssetDatabase.CreateAsset(asset, path);
        }
Exemplo n.º 2
0
        public override void OnImportAsset(AssetImportContext ctx)
        {
            byte[] mideFile = File.ReadAllBytes(ctx.assetPath);

            MidiAsset asset = MidiAsset.CreateInstance <MidiAsset>();

            asset.SetMidiFileRaw(mideFile);

            AssetDatabase.CreateAsset(asset, Path.GetDirectoryName(ctx.assetPath) + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(ctx.assetPath) + ".asset");

            File.Delete(ctx.assetPath);
        }