예제 #1
0
        /// <summary>
        /// Async loads the instrument data.
        /// </summary>
        /// <param name="argResourceDirectory"></param>
        /// <returns></returns>
        public IEnumerator AsyncLoadInstrumentsData(string argResourceDirectory)
        {
            ///Load the instruments:
            InstrumentSet set = MusicGenerator.Instance.mInstrumentSet;

            for (int i = 0; i < MusicGenerator.mMaxInstruments; i++)
            {
                string path = MusicFileConfig.GetConfigDirectory(argResourceDirectory) + "/instruments" + i.ToString() + ".txt";
                if (File.Exists(path))
                {
                    InstrumentData instrumentData = InstrumentData.LoadData(argResourceDirectory, "/instruments" + i.ToString() + ".txt");
                    if (instrumentData == null)
                    {
                        yield break;
                    }
                    MusicGenerator.Instance.AddInstrument(set);
                    yield return(null);

                    set.mInstruments[set.mInstruments.Count - 1].LoadInstrument(instrumentData);
                    int index = 999;
                    yield return(StartCoroutine(MusicGenerator.Instance.AsyncLoadBaseClips(set.mInstruments[set.mInstruments.Count - 1].mData.InstrumentType, ((x) => { index = x; }))));

                    set.mInstruments[set.mInstruments.Count - 1].InstrumentTypeIndex = index;
                }
            }
            yield return(null);
        }
예제 #2
0
        /// <summary>
        /// Loads the data for an instrument.
        /// </summary>
        /// <param name="resourceDirectory"></param>
        private IEnumerator LoadInstrumentsData(string argDirectory, bool async = false)
        {
            UnitySystemConsoleRedirector.Redirect();
            InstrumentSet set = MusicGenerator.Instance.mInstrumentSet;

            for (int i = 0; i < MusicGenerator.mMaxInstruments; i++)
            {
                string path = "/instruments" + i.ToString() + ".txt";

                string data = null;
                yield return(MusicHelpers.GetUWR(mSavesPath + "/" + argDirectory + path, (x) => { data = x.downloadHandler.text; }));

                if (string.IsNullOrEmpty(data))
                {
                    yield break;
                }

                InstrumentData instrumentData = null;
                InstrumentData.LoadData(data, argDirectory, (x) => { instrumentData = x; });
                MusicGenerator.Instance.AddInstrument(set);
                set.mInstruments[set.mInstruments.Count - 1].LoadInstrument(instrumentData);
                int index = 0;
                if (async)
                {
                    yield return(StartCoroutine(MusicGenerator.Instance.AsyncLoadBaseClips(set.mInstruments[set.mInstruments.Count - 1].mData.InstrumentType, ((x) => { index = x; }))));
                }
                else
                {
                    index = MusicGenerator.Instance.LoadBaseClips(set.mInstruments[set.mInstruments.Count - 1].mData.InstrumentType);
                }
                set.mInstruments[set.mInstruments.Count - 1].InstrumentTypeIndex = index;
            }
            yield return(null);
        }
예제 #3
0
        /// <summary>
        /// Loads the data for an instrument.
        /// </summary>
        /// <param name="folderIN"></param>
        private static void LoadInstrumentsData(string folderIN)
        {
            InstrumentSet set       = MusicGenerator.Instance.mInstrumentSet;
            string        configDir = GetConfigDirectory(folderIN);

            for (int i = 0; i < MusicGenerator.mMaxInstruments; i++)
            {
                string path = configDir + "/instruments" + i.ToString() + ".txt";
                if (File.Exists(path))
                {
                    InstrumentData instrumentData = InstrumentData.LoadData(folderIN, "/instruments" + i.ToString() + ".txt");
                    MusicGenerator.Instance.AddInstrument(set);
                    set.mInstruments[set.mInstruments.Count - 1].LoadInstrument(instrumentData);
                    int index = MusicGenerator.Instance.LoadBaseClips(set.mInstruments[set.mInstruments.Count - 1].mData.InstrumentType);
                    set.mInstruments[set.mInstruments.Count - 1].InstrumentTypeIndex = index;
                }
            }
        }