Exemple #1
0
    void Update()
    {
        if (Input.GetKeyDown("9"))
        {
            if (once2 == 1)
            {
                StartRecordC = 1;
                AutoToRecord = false;
                Recording    = true;
                Recordstate  = 1;
            }
        }


        if (Input.GetKeyDown("0"))
        {
            StopRecordC = 1;
            Recording   = false;
            Recordstate = 0;
        }

        //otherstart



        //otherstart

        if (AutoToRecord)
        {
            if (once1 == 0)
            {
                if (Time.fixedTime > StartRecordTime)
                {
                    if (Time.fixedTime < StartRecordTime + 1)
                    {
                        //AutoToRecord = false;
                        StartRecordC = 1;
                        once1        = 1;
                        Recording    = true;
                        Recordstate  = 1;
                    }
                }
            }



            if (once4 == 0)
            {
                if (StopRecordTime != 0)
                {
                    if (Time.fixedTime > StopRecordTime)
                    {
                        if (Time.fixedTime < StopRecordTime + 1)
                        {
                            StopRecordC = 1;
                            Recording   = false;
                            Recordstate = 0;
                        }
                    }
                }
            }
        }



        if (StartRecordC == 1)
        {
            if (once3 == 0)
            {
                if (outputPNG)
                {
                    if (Directory.Exists(Application.dataPath + "/../" + "Recording"))
                    {
                        Directory.Delete(Application.dataPath + "/../" + "Recording", true);
                    }

                    Directory.CreateDirectory(Application.dataPath + "/../" + "Recording");
                }
                else
                {
                    System.IO.Directory.CreateDirectory(RecordName);
                }

                System.IO.Directory.CreateDirectory("RecordVideo");
                once3 = 1;
                print("Untiy正在录制...");
            }
            once2 = 0;
            Time.captureFramerate = frameRate;
            if (StopRecordC != 1)
            {
                if (CurrentFrame == -1)
                {
                    CurrentFrame = Time.frameCount;
                }
                string name = string.Format("{0}/{1:D05}.png", RecordName, Time.frameCount - CurrentFrame + 1);
                //Application.CaptureScreenshot (name);

                DebugUtil.DumpRenderTexture(m_camera.targetTexture, name);
            }
            else
            {
                //exit
                once4        = 1;
                CurrentFrame = -1;
                StopRecordC  = 0;
                StartRecordC = 0;
                once2        = 1;
                once3        = 0;

                if (outputPNG)
                {
                }
                else
                {
                    if (ExportGIF)
                    {
                        //Process.Start ("Assets\\ScreenRecorder\\ffmpeg\\Inputvideo.bat");
                    }
                    else
                    {
                        //Process.Start ("Assets\\ScreenRecorder\\ffmpeg\\Inputvideo_nogif.bat");
                    }
                }



                Time.captureFramerate = defaultfps;

                if (outputPNG)
                {
                    print("录制视频压制到: 工程根目录\\" + RecordName);
                }
                else
                {
                    print("录制视频压制到: 工程根目录\\Recordvideo");
                }
            }
        }

        //state
        if (once2 == 1)
        {
            if (Recordstate == 0)
            {
                if (Recording == true)
                {
                    StartRecordC = 1;
                    AutoToRecord = false;
                    Recordstate  = 1;
                }
            }
        }

        if (once2 == 0)
        {
            if (Recordstate == 1)
            {
                if (Recording == false)
                {
                    Recordstate = 0;
                    StopRecordC = 1;
                }
            }
        }
    }