Esempio n. 1
0
        /// Toggles the entire measure editor panel:
        public void MeasureEditorToggle()
        {
            if (mMusicGenerator.mState == eGeneratorState.initializing)
            {
                return;
            }

            StopAllCoroutines();
            bool isEditing = mAnimator.GetInteger("mState") == 0;

            mMusicGenerator.SetState(isEditing ? eGeneratorState.editorInitializing : eGeneratorState.stopped);
            mAnimator.SetInteger("mState", isEditing ? 4 : 0);
            mStaffPlayer.mPreset.gameObject.SetActive(isEditing ? false : true);
            GetComponentInParent <CanvasGroup>().interactable   = isEditing;
            GetComponentInParent <CanvasGroup>().blocksRaycasts = isEditing;
            if (isEditing)
            {
#if !UNITY_EDITOR && UNITY_ANDROID
                StartCoroutine(LoadPresets());
#else
                LoadPresets();
#endif //!UNITY_EDITOR && UNITY_ANDROID
                //StartCoroutine(AsyncStageClipForPlaying());
            }
            else
            {
                ClearCurrentInstruments();
                mGeneratorPanel.LoadConfigFromUI();
                mStaffPlayer.ClearNotes(true, true);
                mStaffPlayer.ChangeTimeSignature((int)mCurrentInstSet.mTimeSignature.Signature);
            }
        }
        /// Loads a new configuration.
        private IEnumerator NonAsyncLoadNewConfiguration(string configName)
        {
            yield return(StartCoroutine(NonAsyncLoadConfig(configName)));

            NonAsyncLoadUI();
            mGlobalEffectsPanel.Init(mMusicGenerator);
            mMusicGenerator.SetState(eGeneratorState.ready);
            yield return(null);
        }
Esempio n. 3
0
        public IEnumerator Init()
        {
            mMusicGenerator.SetState(eGeneratorState.initializing);
            yield return(StartCoroutine(mMusicGenerator.mMusicFileConfig.LoadConfig(mMusicGenerator.mDefaultConfig, eGeneratorState.initializing)));

            mTooltips = Tooltips.Instance;
            yield return(StartCoroutine(mTooltips.Init()));

            mStaffPlayer = StaffPlayerUI.Instance;

            mInstrumentListPanelUI = InstrumentListPanelUI.Instance;

            mMeasureEditor = MeasureEditor.Instance;
            mMeasureEditor.Init(mMusicGenerator);

            mInstrumentPanelUI = InstrumentPanelUI.Instance;
            mInstrumentPanelUI.Init();

            mAdvancedSettingsPanel = AdvancedSettingsPanel.Instance;
            mAdvancedSettingsPanel.Init();

            mGlobalEffectsPanel = GlobalEffectsPanel.Instance;
            mGlobalEffectsPanel.Init(mMusicGenerator);

            mGeneratorUIPanel = MusicGeneratorUIPanel.Instance;
            bool finished = false;

            yield return(StartCoroutine(mGeneratorUIPanel.Init(mMusicGenerator, (x) => { finished = x; })));

            yield return(new WaitUntil(() => finished));

            mStaffPlayer.Init(mMusicGenerator);
            mStaffPlayer.ChangeTimeSignature(-1);
            mMusicGenerator.SetState(eGeneratorState.ready);
            //mInstrumentListPanelUI.Init(mMusicGenerator);
            yield return(null);
        }
Esempio n. 4
0
        /// <summary>
        /// Resets the instrument set values:
        /// </summary>
        public void Reset()
        {
            if (mMusicGenerator == null)
            {
                return;
            }

            mRepeatCount       = 0;
            mCurrentGroupLevel = 0;

            ProgressionStepsTaken = -1;
            if (mMusicGenerator.mState == eGeneratorState.repeating)
            {
                mMusicGenerator.SetState(eGeneratorState.playing);
            }

            for (int i = 0; i < mInstruments.Count; i++)
            {
                mInstruments[i].ResetInstrument();
            }
        }
Esempio n. 5
0
 /// If you want to autostart music, add listener to the 'Ready" event in your awake method.
 /// Note: the singleton MusicGenerator.Instance may not exist in Awake(), so you'll want a reference to the generator in the main scene
 void AutoStart()
 {
     mMusicGenerator.SetState(eGeneratorState.playing);
 }