private int ControlPlaybackOptions(int x, int y)
        {
            Rect dimensions = new Rect(x, y, position.width - (x * 2), 70);

            GUI.BeginGroup(dimensions);

            if (playbackService == null)
            {
                if (GUI.Button(new Rect(0, 0, dimensions.width, 40), "Play"))
                {
                    playbackService = PlaybackBehavior.Build(loadedRecording, useCustomActors ? ActorBuilderReference() : null, null, loop);
                    playbackService.Play();
                }

                GUI.EndGroup();
                return(50);
            }

            if (GUI.Button(new Rect(dimensions.width / 2 + 5, 0, dimensions.width / 2 - 10, 30), "Stop"))
            {
                playbackService.Stop(true);
                DestroyImmediate(playbackService.gameObject);
            }

            if (playbackService.CurrentlyPlaying() && GUI.Button(new Rect(5, 0, dimensions.width / 2 - 10, 30), "Pause"))
            {
                playbackService.Pause();
            }

            if (playbackService.CurrentlyPaused() && GUI.Button(new Rect(5, 0, dimensions.width / 2 - 10, 30), "Resume"))
            {
                playbackService.Play();
            }

            playbackService.SetPlaybackSpeed(EditorGUI.Slider(new Rect(3, 35, dimensions.width - 6, 20), "Playback Speed", playbackService.GetPlaybackSpeed(), -8, 8));

            float curTime = playbackService.GetTimeThroughPlayback();
            float newTime = EditorGUI.Slider(new Rect(3, 55, dimensions.width - 6, 20), "Current Time", curTime, 0, loadedRecording.GetDuration());

            if (newTime != curTime)
            {
                playbackService.SetTimeThroughPlayback(newTime);
            }

            GUI.EndGroup();
            return(70);
        }
Beispiel #2
0
        void OnGUI()
        {
            switch (recorder.CurrentState())
            {
            case RecordingState.Recording:
                if (recorder.CurrentlyRecording() && GUI.Button(new Rect(10, 10, 120, 25), "Pause"))
                {
                    recorder.Pause();
                }


                if (GUI.Button(new Rect(10, 40, 120, 25), "Finish"))
                {
                    playback = PlaybackBehavior.Build(recorder.Finish(), this, this, true);
                    ClearObjectsToTrack();
                }
                break;

            case RecordingState.Paused:
                if (recorder.CurrentlyPaused() && GUI.Button(new Rect(10, 10, 120, 25), "Resume"))
                {
                    recorder.Resume();
                }

                if (GUI.Button(new Rect(10, 40, 120, 25), "Finish"))
                {
                    playback = PlaybackBehavior.Build(recorder.Finish(), this, this, true);
                    ClearObjectsToTrack();
                }
                break;

            case RecordingState.Stopped:
                if (GUI.Button(new Rect(10, 10, 120, 25), "Start Recording"))
                {
                    recorder.ClearSubjects();
                    SetUpObjectsToTrack();
                    recorder.Start();
                    if (playback != null)
                    {
                        playback.Stop();
                        Destroy(playback.gameObject);
                    }
                }
                if (playback != null)
                {
                    GUI.Box(new Rect(10, 50, 120, 250), "Playback");
                    if (playback.CurrentlyPlaying() == false && GUI.Button(new Rect(15, 75, 110, 25), "Start"))
                    {
                        playback.Play();
                    }

                    if (playback.CurrentlyPlaying() && GUI.Button(new Rect(15, 75, 110, 25), "Pause"))
                    {
                        playback.Pause();
                    }

                    GUI.Label(new Rect(55, 105, 100, 30), "Time");
                    GUI.Label(new Rect(55, 125, 100, 30), playback.GetTimeThroughPlayback().ToString("0.00"));
                    playback.SetTimeThroughPlayback(GUI.HorizontalSlider(new Rect(15, 150, 100, 30), playback.GetTimeThroughPlayback(), 0.0F, playback.RecordingDuration()));

                    GUI.Label(new Rect(20, 170, 100, 30), "Playback Speed");
                    GUI.Label(new Rect(55, 190, 100, 30), playback.GetPlaybackSpeed().ToString("0.00"));
                    playback.SetPlaybackSpeed(GUI.HorizontalSlider(new Rect(15, 215, 100, 30), playback.GetPlaybackSpeed(), -8, 8));

                    if (GUI.Button(new Rect(15, 250, 110, 25), "Save"))
                    {
                        //SaveToAssets(playback.GetRecording(), "Demo");
                        using (FileStream fs = File.Create(string.Format("{0}/demo.rap", Application.dataPath)))
                        {
                            var rec = playback.GetRecording();
                            rec.RecordingName = "Demo";
                            IO.Packager.Package(fs, rec);
                        }
                    }
                }
                break;
            }
        }