右键新增一个rtVoice
加一个button加上这个脚本
using System.Collections;
using System.Collections.Generic;
using Crosstales.RTVoice;
using Crosstales.RTVoice.Model;
using UnityEngine;
using UnityEngine.EventSystems;
public class ButtonclickC : MonoBehaviour, IPointerClickHandler {
public AudioSource SourceA;
// Start is called before the first frame update
void Start() {
Speaker.Instance.OnSpeakAudioGenerationComplete += speakAudioGenerationCompleteMethod;
}
private Wrapper currentWrapper;
private void speakAudioGenerationCompleteMethod(Wrapper wrapper)
{
currentWrapper = wrapper;
Invoke(nameof(speakAudio), 0.1f); //needs a small delay
}
private void speakAudio()
{
Speaker.Instance.SpeakMarkedWordsWithUID(currentWrapper);
}
// Update is called once per frame
void Update() {
}
public void OnPointerClick(PointerEventData eventData) {
print("11");
//Don't speak the text immediately
Speaker.Instance.Speak("官艳军是个傻叉", SourceA,
Speaker.Instance.VoiceForGender(Crosstales.RTVoice.Model.Enum.Gender.FEMALE, "zh", 0, "zh"),
false, 1.25f);
}
}
|