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