예제 #1
0
    private IEnumerator LoadAudio()
    {
        yield return(null);

        audioSource.clip = OggClipLoader.LoadClip(audioFilePath);
        audioLoaded      = true;
        yield return(null);
    }
예제 #2
0
        void OnRender(Model model)
        {
            Filter.SetText(model.filter);
            Keyboard.SetText(model.filter);

            SortBy.options =
                model
                .sortTypes
                .Select(s => new Dropdown.OptionData(s.name))
                .ToList();
            SortBy.value = SortBy.options.FindIndex(x => x.text == model.selectedSortType.name);

            var difficultyOptions =
                model
                .difficulties
                .Select(s => new Dropdown.OptionData(s))
                .ToList();

            Difficulty.options = difficultyOptions;
            Difficulty.value   = difficultyOptions.FindIndex(x => x.text == model.selectedDifficulty);

            foreach (Transform child in Categories.transform)
            {
                Destroy(child.gameObject);
            }
            AddCategoryItems(model.categories, model.selectedCategory);

            foreach (Transform child in Songs.transform)
            {
                Destroy(child.gameObject);
            }
            AddSongItems(model.songs, model.selectedSong);
            if (model.resetSongScrollPosition)
            {
                SongsScroll.ResetYScrollPosition();
            }

            if (model.songState == SongState.LOADING)
            {
                Songs.SetActive(false);
                SongsLoading.SetActive(true);
                foreach (Transform child in Songs.transform)
                {
                    Destroy(child.gameObject);
                }
            }
            else if (model.songState == SongState.LOADED)
            {
                SongsLoading.SetActive(false);
                Songs.SetActive(true);
            }

            if (model.previewState == SongPreviewState.START)
            {
                audioSource.Stop();
                startSongPreview = true;
                previewAudioClip = OggClipLoader.LoadClip(model.previewFilePath);
            }
            else if (model.previewState == SongPreviewState.STOP)
            {
                audioSource.Stop();
                startSongPreview = false;
                previewAudioClip = null;
            }

            // Play buttons for the selected song
            foreach (Transform child in PlayButtons.transform)
            {
                Destroy(child.gameObject);
            }
            if (model.selectedSong != null)
            {
                AddPlayButtons(model.songDifficulties, model.selectedSong?.hash, model.selectedPlayingMethod);
                if (model.selectedDifficulty != "All")
                {
                    HighScoreBoard.Fill(model.selectedSong?.hash, model.selectedDifficulty, model.selectedPlayingMethod);
                    HighScoreBoard.gameObject.SetActive(true);
                }
                else
                {
                    HighScoreBoard.gameObject.SetActive(false);
                }
            }
            else
            {
                HighScoreBoard.gameObject.SetActive(false);
            }
        }