Adventure Creator Wikia
Advertisement

The following is AC's legacy Rogo Digital LipSync integration, condensed into a single standalone script.

To use it:

  1. Copy/paste the code below into a C# file named RogoLipSyncIntegration
  2. Attach the script to your character, and assign the character in the component's "Speaker" field
  3. In the Speech Manager, gather speech text, and set "Lip syncing" to "Custom".
  4. 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

}
Advertisement