Beispiel #1
0
        void OnGUI()
        {
            if (!EditorApplication.isPlaying || Settings.s == null)
            {
                EditorGUILayout.HelpBox("Please start the scene to use this window.", MessageType.Info);
                t = null;
                return;
            }

            if (t == null)
            {
                t = Instantiate(MapLoader.Loader.controller.recordingToolPrefab);
            }

            GUILayout.BeginHorizontal();

            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            var centeredStyle = new GUIStyle(GUI.skin.label);

            centeredStyle.alignment = TextAnchor.MiddleCenter;

            GUILayout.EndHorizontal();

            GUILayout.BeginVertical();
            GUILayout.Label("Status: " + t.State.ToString());
            GUILayout.BeginHorizontal();

            if (t.State != RecordingTool.RecordingState.Recording)
            {
                if (GUILayout.Button("Start Recording"))
                {
                    t.StartRecording();
                }
            }
            else
            {
                if (GUILayout.Button("Stop Recording"))
                {
                    t.StopRecording();
                }
            }

            EditorGUI.BeginDisabledGroup(t.State != RecordingTool.RecordingState.Playback);
            DrawPlayControls(t);
            EditorGUI.EndDisabledGroup();

            EditorGUI.BeginDisabledGroup(t.State == RecordingTool.RecordingState.Idle);
            if (GUILayout.Button("Reset"))
            {
                t.Reset();
            }

            GUILayout.EndHorizontal();
            t.CurrentTime = GUILayout.HorizontalSlider(t.CurrentTime, 0.0f, t.Data?.Duration ?? 0);
            GUILayout.Space(20);
            GUILayout.BeginHorizontal();

            GUILayout.Label("Playback Speed");
            string playbackSpeed = GUILayout.TextField(t.PlaybackSpeed.ToString("#.##"));

            float.TryParse(playbackSpeed, out t.PlaybackSpeed);

            if (GUILayout.Button("-1x"))
            {
                t.PlaybackSpeed = -1;
            }
            if (GUILayout.Button("0.5x"))
            {
                t.PlaybackSpeed = 0.5f;
            }
            if (GUILayout.Button("1x"))
            {
                t.PlaybackSpeed = 1;
            }
            if (GUILayout.Button("2x"))
            {
                t.PlaybackSpeed = 2;
            }

            GUILayout.EndHorizontal();

            EditorGUI.EndDisabledGroup();

            GUILayout.Space(30);
            GUILayout.EndVertical();

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Save to Clipboard"))
            {
                GUIUtility.systemCopyBuffer = JsonConvert.SerializeObject(t.Data);;
            }
            if (GUILayout.Button("Paste from Clipboard"))
            {
                t.Data = JsonConvert.DeserializeObject <RecordingTool.RecordingData>(GUIUtility.systemCopyBuffer);
            }
            GUILayout.EndHorizontal();

            t.AlignCameraToGame     = EditorGUILayout.Toggle("Align Unity's Camera with Game Camera", t.AlignCameraToGame);
            t.InterpolateTransforms = EditorGUILayout.Toggle("Interpolate object transforms during playback", t.InterpolateTransforms);

            if (GUILayout.Button("(DEBUG) Show Spawned Always Objects"))
            {
                alwaysNameList = new List <string>();
                if (t.SpawnedAlwaysObjects != null)
                {
                    foreach (var spo in t.SpawnedAlwaysObjects.Values)
                    {
                        alwaysNameList.Add(spo.perso.fullName);
                    }
                }
            }

            GUILayout.BeginVertical();
            if (alwaysNameList != null)
            {
                foreach (var spo in alwaysNameList)
                {
                    GUILayout.Label(spo);
                }
            }
            GUILayout.EndVertical();
        }
Beispiel #2
0
        public void StopRecording()
        {
            bool wait_streams            = false;
            bool wait_controller_streams = false;
            bool wait_eye_streams        = false;
            bool wait_mouth_streams      = false;
            bool wait_voices             = false;
            bool wait_hearing            = false;
            bool wait_vision             = false;
            bool wait_anim = false;

            //STREAMS
            if (streamRecorder.isRecording)
            {
                streamRecorder.StopRecording();
                wait_streams = true;
            }

            //CONTROLLER STREAMS
            if (controllerRecorder.isRecording)
            {
                controllerRecorder.StopRecording();
                wait_controller_streams = true;
            }

            //EYE STREAMS
            if (eyeRecorder.isRecording)
            {
                eyeRecorder.StopRecording();
                wait_eye_streams = true;
            }

            //MOUTH STREAMS
            if (mouthRecorder.isRecording)
            {
                mouthRecorder.StopRecording();
                wait_mouth_streams = true;
            }

            //VOICES
            if (voiceRecorder.isRecording)
            {
                voiceRecorder.StopRecording();
                wait_voices = true;
            }

            //HEARING
            if (metagen_comp.hearingRecorder != null && metagen_comp.hearingRecorder.isRecording)
            {
                metagen_comp.hearingRecorder.StopRecording();
                wait_hearing = true;
            }

            //VISION
            if (visionRecorder.isRecording)
            {
                visionRecorder.StopRecording();
                wait_vision = true;
            }

            //BVH
            if (bvhRecorder.isRecording)
            {
                bvhRecorder.StopRecording();
            }

            try
            {
                if (animationRecorder.isRecording)
                {
                    animationRecorder.PreStopRecording();
                    wait_anim = true;
                }
            } catch (Exception e)
            {
                UniLog.Log(">w< animation stopping failed");
            }


            Task task = Task.Run(() =>
            {
                try
                {
                    //STREAMS
                    if (wait_streams)
                    {
                        streamRecorder.WaitForFinish();
                        wait_streams = false;
                    }

                    //CONTROLLER STREAMS
                    if (wait_controller_streams)
                    {
                        controllerRecorder.WaitForFinish();
                        wait_controller_streams = false;
                    }

                    //EYE STREAMS
                    if (wait_eye_streams)
                    {
                        eyeRecorder.WaitForFinish();
                        wait_eye_streams = false;
                    }

                    //MOUTH STREAMS
                    if (wait_mouth_streams)
                    {
                        mouthRecorder.WaitForFinish();
                        wait_mouth_streams = false;
                    }

                    //VOICES
                    if (wait_voices)
                    {
                        UniLog.Log("Waiting voices");
                        voiceRecorder.WaitForFinish();
                        wait_voices = false;
                        UniLog.Log("Waited voices");
                    }

                    //HEARING
                    if (wait_hearing)
                    {
                        metagen_comp.hearingRecorder.WaitForFinish();
                        wait_hearing = false;
                    }

                    //VISION
                    if (wait_vision)
                    {
                        visionRecorder.WaitForFinish();
                        wait_vision = false;
                    }

                    metagen.Util.MediaConverter.WaitForFinish();

                    //ANIMATION
                    if (wait_anim)
                    {
                        animationRecorder.StopRecording();
                        animationRecorder.WaitForFinish();
                        metagen_comp.World.RunSynchronously(() =>
                        {
                            metagen_comp.Slot.RemoveComponent(animationRecorder);
                        });
                        wait_anim = false;
                    }
                } catch (Exception e)
                {
                    UniLog.Log("OwO error in waiting task when stopped recording: " + e.Message);
                    UniLog.Log(e.StackTrace);
                } finally
                {
                    UniLog.Log("FINISHED STOPPING RECORDING");
                    metagen_comp.recording_state = OutputState.Stopped;
                    metagen_comp.dataManager.StopSection();
                }
            });

            //task.ContinueWith((Task t) =>
            //{
            //    UniLog.Log("FINISHED STOPPING RECORDING");
            //    this.recording_state = OutputState.Stopped;
            //    dataManager.StopSection();
            //});
            isRecording = false;
        }
Beispiel #3
0
 public void StopPlaying()
 {
     Task.Run(async() => await channel.ShutdownAsync());
     output_readers         = new Dictionary <RefID, IAsyncStreamReader <Bones> >();
     fake_proxies           = new Dictionary <RefID, List <Tuple <BodyNode, AvatarObjectSlot> > >();
     avatar_stream_channels = new Dictionary <RefID, Dictionary <BodyNode, Tuple <bool, bool, bool> > >();
     hands_are_tracked      = new Dictionary <RefID, bool>();
     proxy_slots            = new Dictionary <RefID, Dictionary <BodyNode, Slot> >();
     user_ids = new List <RefID>();
     avatarManager.avatar_template     = null;
     avatarManager.has_prepared_avatar = false;
     if (generateAnimation || generateBvh)
     {
         if (generateBvh)
         {
             bvhRecorder.StopRecording();
         }
         if (generateAnimation)
         {
             animationRecorder.PreStopRecording();
             metagen_comp.World.RunSynchronously(() =>
             {
                 animationRecorder.StopRecording();
             });
         }
         Task.Run(() =>
         {
             if (generateAnimation)
             {
                 animationRecorder.WaitForFinish();
             }
             metagen_comp.World.RunSynchronously(() =>
             {
                 UniLog.Log("AVATARS COUNT KEK");
                 UniLog.Log(avatars.Count);
                 if (generateAnimation)
                 {
                     metagen_comp.Slot.RemoveComponent(animationRecorder);
                 }
                 foreach (var item in avatars)
                 {
                     Slot slot = item.Value;
                     slot.Destroy();
                 }
                 avatars              = new Dictionary <RefID, Slot>();
                 finger_slots         = new Dictionary <RefID, Dictionary <BodyNode, Slot> >();
                 hand_posers          = new Dictionary <RefID, Dictionary <Chirality, HandPoser> >();
                 finger_compensations = new Dictionary <RefID, Dictionary <BodyNode, floatQ> >();
             });
         });
     }
     else
     {
         UniLog.Log("AVATARS COUNT KEK");
         UniLog.Log(avatars.Count);
         foreach (var item in avatars)
         {
             Slot slot = item.Value;
             slot.Destroy();
         }
         avatars              = new Dictionary <RefID, Slot>();
         finger_slots         = new Dictionary <RefID, Dictionary <BodyNode, Slot> >();
         hand_posers          = new Dictionary <RefID, Dictionary <Chirality, HandPoser> >();
         finger_compensations = new Dictionary <RefID, Dictionary <BodyNode, floatQ> >();
     }
     isPlaying = false;
 }