Unity引用DLL文件
using UnityEngine;using System;
using System.Collections;
using System.Runtime.InteropServices;
public class VoiceSpeaker : MonoBehaviour
{
private static extern int VoiceAvailable();
private static extern void InitVoice();
private static extern int WaitUntilDone(int millisec);
private static extern void FreeVoice();
private static extern int GetVoiceCount();
private static extern string GetVoiceName(int index);
private static extern void SetVoice(int index);
private static extern void Say(string ttospeak);
private static extern void SayAndWait(string ttospeak);
private static extern int SpeakToFile(string filename, string ttospeak);
private static extern int GetVoiceState();
private static extern int GetVoiceVolume();
private static extern void SetVoiceVolume(int volume);
private static extern int GetVoiceRate();
private static extern void SetVoiceRate(int rate);
private static extern void PauseVoice();
private static extern void ResumeVoice();
public int voice_nb = 0;
void Start()
{
if (VoiceAvailable() > 0)
{
InitVoice(); // init the engine
Debug.Log("Number of voice : " + GetVoiceCount()); // Number of voice
SetVoice(voice_nb); // 0 to voiceCount - 1
Debug.Log("Voice name : " + GetVoiceName(voice_nb));
Say("Hello. I can speak now. My name is " + GetVoiceName(voice_nb) + ". Welcome to Unity"+"Ãû×Ö");
}
}
void OnDisable()
{
if (VoiceAvailable() > 0)
{
FreeVoice();
}
}
}
好东西 好东西 楼主是超人 顶顶多好 难得一见的好帖 很好哦 LZ真是人才 好帖就是要顶 顶顶多好 难得一见的好帖
页:
[1]