Пример #1
0
        /// <summary>
        /// Load setting (edit mode)
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public static MidiSet Load(string path)
        {
            MidiSet loaded = null;

            try
            {
                if (File.Exists(path))
                {
                    var serializer = new XmlSerializer(typeof(MidiSet));
                    using (var stream = new FileStream(path, FileMode.Open))
                    {
                        loaded = serializer.Deserialize(stream) as MidiSet;
                    }
                }
                else
                {
                    loaded = new MidiSet();
                }
            }
            catch (System.Exception ex)
            {
                MidiPlayerGlobal.ErrorDetail(ex);
            }

            return(loaded);
        }
Пример #2
0
 public static void LoadMidiSet()
 {
     try
     {
         MidiPlayerGlobal.CurrentMidiSet = MidiSet.Load(Application.dataPath + "/" + MidiPlayerGlobal.PathToMidiSet);
         if (MidiPlayerGlobal.CurrentMidiSet.MidiFiles == null)
         {
             MidiPlayerGlobal.CurrentMidiSet.MidiFiles = new List <string>();
         }
     }
     catch (System.Exception ex)
     {
         MidiPlayerGlobal.ErrorDetail(ex);
     }
 }
Пример #3
0
 private static void LoadMidiSetFromRsc()
 {
     try
     {
         TextAsset sf = Resources.Load <TextAsset>(MidiPlayerGlobal.FilenameMidiSet);
         if (sf == null)
         {
             Debug.LogWarning(MidiPlayerGlobal.ErrorNoMidiFile);
         }
         else
         {
             //UnityEngine.Debug.Log(sf.text);
             CurrentMidiSet = MidiSet.LoadRsc(sf.text);
         }
     }
     catch (System.Exception ex)
     {
         MidiPlayerGlobal.ErrorDetail(ex);
     }
 }
Пример #4
0
        /// <summary>
        /// LOad setting (run mode)
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public static MidiSet LoadRsc(string data)
        {
            MidiSet loaded = null;

            try
            {
                if (!string.IsNullOrEmpty(data))
                {
                    var serializer = new XmlSerializer(typeof(MidiSet));
                    using (TextReader reader = new StringReader(data))
                    {
                        loaded = serializer.Deserialize(reader) as MidiSet;
                    }
                }
            }
            catch (System.Exception ex)
            {
                MidiPlayerGlobal.ErrorDetail(ex);
            }

            return(loaded);
        }