Exemple #1
0
/*+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
 * SONG CONTROLS
 *+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=*/

    void DrawNavSettings()
    {
        GUILayout.BeginArea(navBarSection);
        GUILayout.Label("Navigation");

        game           = FindObjectOfType <Game>();
        songController = FindObjectOfType <SongController>();

        GUILayout.BeginHorizontal();
        if (songData == null)
        {
            songData = game.GetEditorSong();
        }
        SongData newData = (SongData)EditorGUILayout.ObjectField(songData, typeof(SongData), true, GUILayout.MaxWidth(187));

        if (songData != newData)
        {
            Debug.Log("CHANGE SONG TO " + newData.name);
            songData = newData;
            game.SetEditorSong(songData);
            game.ReloadBallData();
            EditorUtility.SetDirty(game);
        }
        GUILayout.EndHorizontal();

        if (songData != null)
        {
            EditorGUILayout.BeginHorizontal();

            // Restart Song
            if (GUILayout.Button("<<", GUILayout.Height(navButtonHeight), GUILayout.Width(navButtonWidth)))
            {
                songController.JumpToStart();
            }

            // Go Back 8 beats
            if (GUILayout.Button("<", GUILayout.Height(navButtonHeight), GUILayout.Width(navButtonWidth)))
            {
                songController.JumpToBeat(songController.GetSongTimeBeats() - 8);
            }

            // Pause/Play
            if (GUILayout.Button("Play", GUILayout.Height(navButtonHeight), GUILayout.Width(navButtonWidth)))
            {
                songController.JumpToBeat(jumpToTime);
            }

            // Go Forward 8 beats
            if (GUILayout.Button(">", GUILayout.Height(navButtonHeight), GUILayout.Width(navButtonWidth)))
            {
                songController.JumpToBeat(songController.GetSongTimeBeats() + 8);
            }

            // Go to end of song
            if (GUILayout.Button(">>", GUILayout.Height(navButtonHeight), GUILayout.Width(navButtonWidth)))
            {
                songController.JumpToEnd();
            }

            // Current Beat
            if (Application.isPlaying)
            {
                GUILayout.Label("Beat: " + songController.GetSongTimeBeats(), GUILayout.Width(100));
            }

            // Song Slider
            jumpToTime = (int)EditorGUILayout.Slider((float)jumpToTime, songData.startBeat, songData.endBeat);

            EditorGUILayout.EndHorizontal();
        }
        GUILayout.EndArea();
    }