using System; using UnityEngine; [RequireComponent(typeof(AudioSource))] public class OVRLipSyncContextBase : MonoBehaviour { public int Smoothing { set { OVRLipSync.SendSignal(this.context, OVRLipSync.Signals.VisemeSmoothing, value, 0); } } public uint Context { get { return this.context; } } protected OVRLipSync.Frame Frame { get { return this.frame; } } public virtual void Init() { if (!this.audioSource) { this.audioSource = base.GetComponent(); } lock (this) { if (this.context == 0U && OVRLipSync.CreateContext(ref this.context, this.provider) != OVRLipSync.Result.Success) { Debug.Log("OVRPhonemeContext.Start ERROR: Could not create Phoneme context."); } } } private void OnDestroy() { lock (this) { if (this.context != 0U && OVRLipSync.DestroyContext(this.context) != OVRLipSync.Result.Success) { Debug.Log("OVRPhonemeContext.OnDestroy ERROR: Could not delete Phoneme context."); } } } public OVRLipSync.Frame GetCurrentPhonemeFrame() { return this.frame; } public void SetVisemeBlend(int viseme, int amount) { OVRLipSync.SendSignal(this.context, OVRLipSync.Signals.VisemeAmount, viseme, amount); } public OVRLipSync.Result ResetContext() { return OVRLipSync.ResetContext(this.context); } public AudioSource audioSource; public OVRLipSync.ContextProviders provider; [SerializeField] private OVRLipSync.Frame frame = new OVRLipSync.Frame(); private uint context; }