Version: 2018.2
public static AudioClip Start (string deviceName, bool loop, int lengthSec, int frequency);

パラメーター

deviceNameデバイス名
loopループ録音を行なうかどうか、行なう場合は lengthSec に到達したときにクリップの最初に戻って録音を継続する
lengthSec録音するオーディオクリップの長さ
frequency録音するオーディオクリップの周波数

戻り値

AudioClip 録音を開始できなかった場合 false を返す

説明

デバイス名を指定して録音を開始します

デバイス名に null や空の文字列を渡すと、デフォルトのマイクが使用されます。利用可能なマイクデバイスの一覧を devices プロパティーにより取得できます。GetDeviceCaps プロパティーを使用して、マイクでサポートされているサンプルレートの範囲を調べることができます。

Note that if you want to use the Microphone class in the web player, you need to get the user's permission to do so. Call Application.RequestUserAuthorization before calling any Microphone methods.

using UnityEngine;

public class Example : MonoBehaviour { // Start recording with built-in Microphone and play the recorded audio right away void Start() { AudioSource audioSource = GetComponent<AudioSource>(); audioSource.clip = Microphone.Start("Built-in Microphone", true, 10, 44100); audioSource.Play(); } }

5.4.0 以降では、web player はサポートされないことに注意してください。

Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961