1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- 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<AudioSource>();
- }
- 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;
- }
|