Ejemplo n.º 1
0
        /// non async changes the instrument.
        private bool NonAsyncInstrumentChange()
        {
            if (mMusicGenerator.mState < eGeneratorState.ready)
            {
                return(true);
            }

            InstrumentSet set = (mMusicGenerator.mState >= eGeneratorState.editorInitializing) ?
                                MeasureEditor.Instance.mCurrentInstSet : mMusicGenerator.mInstrumentSet;

            int    typeToRemove    = (int)mInstrument.InstrumentTypeIndex;
            int    instrumentIndex = 0;
            string name            = mInstrumentDropdown.options[mInstrumentDropdown.value].text;

            if (name == "dummyEntry")
            {
                return(false);
            }
            string instrumentType = mInstrumentDropdown.options[mInstrumentDropdown.value].text;

            instrumentType = instrumentType.ToLower();

            if (mMusicGenerator.LoadedInstrumentNames.Contains(instrumentType) == false)
            {
                instrumentIndex = mMusicGenerator.LoadBaseClips(instrumentType);
            }
            else
            {
                instrumentIndex = mMusicGenerator.LoadedInstrumentNames.IndexOf(instrumentType);
            }

            List <Instrument> instruments = set.mInstruments;

            int value = GetComponentInChildren <Dropdown>().value;

            if (mInstrument != null)
            {
                instruments[(int)mInstrument.InstrumentIndex].InstrumentTypeIndex  = instrumentIndex;
                instruments[(int)mInstrument.InstrumentIndex].mData.InstrumentType = instrumentType;
                mMuteToggle.isOn = instruments[(int)mInstrument.InstrumentIndex].mData.mIsMuted;
            }
            mMusicGenerator.RemoveBaseClip(typeToRemove, set);
            mMusicGenerator.CleanUpInstrumentTypeIndices(set);
            return(true);
        }