Exemplo n.º 1
0
        public static RhubarbTrack Auto(string rhubarbPath, string audioPath, string dialog, bool _isG = true, bool _isH = true, bool _isX = true)
        {
            rhubarbPath = FixPath(rhubarbPath);
            audioPath   = FixPath(audioPath);
            string dialogPath = FixPath(Path.Combine(Directory.GetCurrentDirectory(), "Assets/dialog.txt"));

            RhubarbTrack rhubarbTrack = ScriptableObject.CreateInstance <RhubarbTrack>();

            rhubarbTrack.keyframes = new List <RhubarbKeyframe>();

            bool   isDialog = !string.IsNullOrEmpty(dialog);
            string extendedMouthShapesArgument = ExtendedMouthShapeArgument(_isG, _isH, _isX);

            if (isDialog)
            {
                File.WriteAllText(dialogPath, dialog);
            }

            Process process = new Process();

#if UNITY_EDITOR_WIN
            process.StartInfo.FileName = rhubarbPath;
            string command = "";
            command += "\"" + audioPath + "\" ";
            command += isDialog ? "--dialogFile \"" + dialogPath + "\" " : "";
            command += "--extendedShapes " + extendedMouthShapesArgument;
            process.StartInfo.Arguments = command;
#endif

#if UNITY_EDITOR_OSX
            process.StartInfo.FileName = "/bin/bash";
            string command = rhubarbPath + " ";
            command += audioPath + " ";
            command += isDialog ? "--dialogFile " + dialogPath + " " : "";
            command += "--extendedShapes " + extendedMouthShapesArgument;
            process.StartInfo.Arguments = "-c \" " + command + " \"";
#endif

            process.StartInfo.UseShellExecute        = false;
            process.StartInfo.RedirectStandardOutput = true;
            process.StartInfo.RedirectStandardError  = true;

            process.Start();

            while (!process.StandardOutput.EndOfStream)
            {
                string          line     = process.StandardOutput.ReadLine();
                RhubarbKeyframe keyframe = new RhubarbKeyframe();
                keyframe.Deserialize(line);
                rhubarbTrack.keyframes.Add(keyframe);
            }

            if (isDialog)
            {
                File.Delete(dialogPath);
            }

            return(rhubarbTrack);
        }
Exemplo n.º 2
0
 public void Deserialize(string text)
 {
     keyframes = new List <RhubarbKeyframe>();
     string[] lines = text.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None);
     for (int i = 0; i < lines.Length; i++)
     {
         RhubarbKeyframe keyframe = new RhubarbKeyframe();
         if (keyframe.Deserialize(lines[i]))
         {
             keyframes.Add(keyframe);
         }
     }
 }