Beispiel #1
0
        public override void OnInspectorGUI()
        {
            SceneRecorder sceneRecorder = (SceneRecorder)target;

            DrawDefaultInspector();

            if (GUILayout.Button("Create Video File"))
            {
                string filename = string.Format("{0}-{1}.mp4", BowieTime.GetDayString(), BowieTime.GetTimeString());

                ProcessStartInfo startInfo = new ProcessStartInfo()
                {
                    FileName  = "/usr/local/bin/ffmpeg",
                    Arguments = "-framerate 25 -pattern_type glob -i '" + sceneRecorder.folder + "/frame-*.png' -vf \"scale=trunc(iw/2)*2:trunc(ih/2)*2\" -c:v libx264 -r 30 -pix_fmt yuv420p " + filename,
                    RedirectStandardOutput = true,
                    RedirectStandardInput  = true,
                    RedirectStandardError  = true,
                    UseShellExecute        = false,
                    WorkingDirectory       = sceneRecorder.folder + '/',
                };

                Process process = new Process()
                {
                    StartInfo = startInfo,
                };

                process.EnableRaisingEvents = false;
                process.OutputDataReceived += (object sender, DataReceivedEventArgs eventArgs) => {
                    UnityEngine.Debug.Log(eventArgs.Data);
                };

                process.ErrorDataReceived += (object sender, DataReceivedEventArgs eventArgs) => {
                    UnityEngine.Debug.Log(eventArgs.Data);
                };

                process.Start();

                process.BeginOutputReadLine();
                process.BeginErrorReadLine();
            }

            if (GUILayout.Button("Remove Image Files"))
            {
                ProcessStartInfo startInfo = new ProcessStartInfo()
                {
                    FileName  = "/bin/rm",
                    Arguments = "\"" + sceneRecorder.folder + "/\"frame-*.png",
                    RedirectStandardOutput = true,
                    RedirectStandardInput  = true,
                    RedirectStandardError  = true,
                    UseShellExecute        = false,
                    WorkingDirectory       = sceneRecorder.folder + '/',
                };

                Process process = new Process()
                {
                    StartInfo = startInfo,
                };

                process.EnableRaisingEvents = false;
                process.OutputDataReceived += (object sender, DataReceivedEventArgs eventArgs) => {
                    UnityEngine.Debug.Log(eventArgs.Data);
                };

                process.ErrorDataReceived += (object sender, DataReceivedEventArgs eventArgs) => {
                    UnityEngine.Debug.Log(eventArgs.Data);
                };

                process.Start();

                process.BeginOutputReadLine();
                process.BeginErrorReadLine();
            }
        }
Beispiel #2
0
 void Update()
 {
     _text.text = string.Format("{0}\n{1:0.000} of today, {2:0.000} of year", BowieTime.NowStr(), BowieTime.PercentOfDay(), BowieTime.PercentOfYear());
 }
Beispiel #3
0
        public void Now()
        {
            double result = BowieTime.Now();

            Assert.GreaterOrEqual(result, 1473515478745d);
        }
Beispiel #4
0
        public void PercentOfYear()
        {
            DateTime time = new DateTime(2009, 7, 1, 0, 0, 0);

            Assert.True(BowieMath.CompareFloats(0.5f, BowieTime.PercentOfYear(time), 0.01f));
        }
Beispiel #5
0
        public void PercentOfDay()
        {
            DateTime time = new DateTime(2008, 3, 1, 12, 0, 0);

            Assert.True(BowieMath.CompareFloats(0.5f, BowieTime.PercentOfDay(time), 0.0001f));
        }
Beispiel #6
0
        public void NowStr()
        {
            string result = BowieTime.NowStr();

            Assert.AreEqual(result.Length, 13);
        }