0

我想检查用户是否对着麦克风说话。我试过了,但没有用。我怎样才能做到这一点?

我的代码是:

using UnityEngine;
using System.Collections;

public class Example : MonoBehaviour 
{
    AudioClip sound;
    string dname;

    // Use this for initialization
    void Start ()
    {

    }

    // Update is called once per frame
    void Update () 
    {
        foreach(string device in Microphone.devices)
        {
            dname=device;
        }
        sound=Microphone.Start(dname,true,10, 44100);
        //here check user speak to microphone or not.
    }
}
4

0 回答 0