Version: 5.3 (switch to 5.4b)
언어English
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

AudioSource.PlayOneShot

Suggest a change

Success!

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.

닫기

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

닫기

취소

Switch to Manual
public function PlayOneShot(clip: AudioClip, volumeScale: float = 1.0F): void;
public void PlayOneShot(AudioClip clip, float volumeScale = 1.0F);
public function PlayOneShot(clip: AudioClip, volumeScale: float = 1.0F): void;
public void PlayOneShot(AudioClip clip, float volumeScale = 1.0F);

파라미터

clip 재생되고 있는 클립입니다.
volumeScale 볼륨의 크기입니다. (0-1)

Description

AudioClip을 재생하며, volumeScale에 의해 AudioSource 볼륨을 스케일합니다.


        
using UnityEngine;
using System.Collections;

[RequireComponent(typeof(AudioSource))] public class ExampleClass : MonoBehaviour { public AudioClip impact; AudioSource audio; void Start() { audio = GetComponent<AudioSource>(); } void OnCollisionEnter() { audio.PlayOneShot(impact, 0.7F); } }

See Also: AudioSource.Play.