お好みのスクリプト言語を選択すると、サンプルコードがその言語で表示されます。
Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.
ClosedeviceName | デバイス名 |
loop | ループ録音を行なうか。行なう場合 lengthSec に到達した時にクリップの最初に戻って録音を継続する |
lengthSec | 録音するオーディオクリップの長さ |
frequency | 録音するオーディオクリップの周波数 |
AudioClip 録音を開始できなかった場合 false を返します
デバイス名を指定して録音を開始します
デバイス名に空文字 や null を渡した場合、デフォルトのマイクのデバイスが使用されます。 devices プロパティにより利用可能なマイクのデバイス一覧を取得できます。マイクが対応している周波数の範囲は GetDeviceCaps プロパティにより確認できます。 ウェブプレイヤーで Microphone クラスを使用したい場合、 ユーザのパーミッションを取得する必要があることに留意して下さい。任意の Microphone メソッド呼び出しの前に Application.RequestUserAuthorizationを 呼び出しして下さい。
// Start recording with built-in Microphone and play the recorded audio right away function Start() { var aud = GetComponent.<AudioSource>(); aud.clip = Microphone.Start("Built-in Microphone", true, 10, 44100); aud.Play(); }
using UnityEngine; using System.Collections; public class ExampleClass : MonoBehaviour { void Start() { AudioSource aud = GetComponent<AudioSource>(); aud.clip = Microphone.Start("Built-in Microphone", true, 10, 44100); aud.Play(); } }
import UnityEngine import System.Collections public class ExampleClass(MonoBehaviour): def Start() as void: aud as AudioSource = GetComponent[of AudioSource]() aud.clip = Microphone.Start('Built-in Microphone', true, 10, 44100) aud.Play()