The following is AC's legacy Rogo Digital LipSync integration, condensed into a single standalone script.
To use it:
- Copy/paste the code below into a C# file named RogoLipSyncIntegration
- Attach the script to your character, and assign the character in the component's "Speaker" field
- In the Speech Manager, gather speech text, and set "Lip syncing" to "Custom".
- For each line, associate each line with the lipsync data file, according to your chosen "Reference speech files" option
using UnityEngine;
using AC;
public class RogoLipSyncIntegration : MonoBehaviour
{
#region Variables
[SerializeField] private AC.Char speaker = null;
#endregion
#region UnityStandards
private void OnEnable ()
{
EventManager.OnStartSpeech_Alt += OnStartSpeech;
EventManager.OnStopSpeech_Alt += OnStopSpeech;
}
private void OnDisable ()
{
EventManager.OnStartSpeech_Alt -= OnStartSpeech;
EventManager.OnStopSpeech_Alt -= OnStopSpeech;
}
#endregion
#region CustomEvents
private void OnStartSpeech (Speech speech)
{
if (speech.GetSpeakingCharacter () == speaker)
{
if (lineID > -1)
{
LipSyncData lipSyncData = KickStarter.runtimeLanguages.GetSpeechLipsyncFile <LipSyncData> (speech.lineID, speaker);
if (lipSyncData != null)
{
LipSync lipSync = speaker.GetComponent <LipSync>();
if (lipSync && lipSync.enabled)
{
lipSync.Play (lipSyncData);
speech.hasAudio = true;
}
}
}
/*AudioSource lipsyncSource = RogoLipSyncIntegration.Play (_speaker, lineID, Options.GetVoiceLanguageName ());
if (lipsyncSource)
{
speech.hasAudio = true;
}*/
}
}
private void OnStopSpeech (Speech speech)
{
if (speech.GetSpeakingCharacter () == speaker)
{
LipSync lipSync = speaker.GetComponentInChildren <LipSync>();
if (lipSync && lipSync.enabled)
{
lipSync.Stop (true);
}
}
}
#endregion
}