Version: 2022.1
언어: 한국어
WebGL graphics
Embedded Resources in WebGL

WebGL의 오디오

This page only provides information about audio capabilities in WebGL. To learn how to use audio in your Unity project, see the Audio Overview.

Unity는 FMOD를 사용하여 플랫폼용 오디오를 관리하므로 Unity WebGL은 오디오 기능을 제한적으로 지원(기본 기능만 포함)합니다. FMOD는 WebGL이 지원하지 않는 스레드에 의존합니다. 이러한 이유로 Unity는 브라우저가 오디오 재생 및 믹싱을 처리하도록 지원하는 내부 Web Audio API 기반 구현을 사용합니다.

Note: Google Chrome’s new Autoplay policy prevents autoplay of audio and video under certain conditions. For example, while your game might be set to autoplay some background music soon after the game loads, it won’t play automatically unless you click or tap on the website. For more information on how to enable or disable this policy, see Google Chrome’s documentation on Autoplay policy in Chrome.

지원되는 클래스

Unity WebGL은 다음 API 클래스를 지원합니다.

클래스 WebGL 지원 상태
AudioSource WebGL supports some APIs. See AudioSource for specific support details.
AudioListener 모든 API가 지원됩니다.
AudioClip WebGL은 일부 API를 지원합니다. 자세한 지원 내용은 AudioClip을 참조하십시오.
SystemInfo.supportsAudio 브라우저가 WebGL에 대한 오디오 지원을 제공합니다. 이러한 이유로 SystemInfo.supportsAudio는 항상 true입니다.
Microphone 지원되지 않음.

오디오 소스

AudioSource API는 다음을 포함한 기본 포지션 오디오 재생을 지원합니다.

  • 일시정지 및 다시 시작
  • 패닝
  • 롤오프
  • 피치 설정
  • 도플러 효과 지원

Unity WebGL은 다음 AudioSource API를 지원합니다.

Settings 설명
Clip 다음에 재생할 오디오 클립을 결정합니다.
dopplerLevel AudioSource의 도플러 스케일을 설정합니다.
ignoreListenerPause AudioSource가 AudioListener.pause를 무시하고 오디오를 계속 재생하도록 허용합니다.
ignoreListenerVolume 최종 사용자의 AudioSource 볼륨을 무시합니다.
isPlaying AudioSource.clip이 재생 중이면 true를 반환합니다.
loop 애플리케이션이 AudioSource.clip을 반복하도록 허용합니다.
maxDistance AudioSource.clip이 감쇠를 멈추거나 들리지 않게 되는 최대 거리를 설정합니다.
minDistance AudioSource.clip의 볼륨이 더 이상 증가하지 않는 최소 거리를 설정합니다. 소리가 최소 거리 이상으로 감쇠되기 시작합니다.
mute AudioSource를 음소거합니다.
pitch AudioSource.clip의 피치를 설정합니다. WebGL은 양수 피치 값만 지원합니다.
playOnAwake 활성 상태일 때 AudioSource를 재생합니다.
rolloffMode 거리에 따른 AudioSource 감쇠를 설정합니다.
time 재생 포지션을 초 단위로 설정합니다.
timeSamples 펄스 코드 변조(PCM) 샘플의 재생 포지션을 설정합니다.
velocityUpdateMode AudioSource가 고정 또는 동적 업데이트 루프에서 업데이트되는지 여부를 설정합니다.
volume AudioSource의 볼륨을 설정합니다(0.0–1.0).
Pause AudioSource.clip을 일시정지합니다.
Play AudioSource.clip을 재생합니다.
PlayDelayed 지정한 지연 시간(초)으로 AudioSource.clip을 재생합니다.
PlayOneShot AudioClip을 재생하고 volumeScale로 AudioSource 볼륨을 조정합니다.
PlayScheduled 지정된 시간에 AudioSource를 재생합니다.
SetScheduledEndTime 예약된 AudioSource.clip이 종료되는 시간을 설정합니다.
SetScheduledStartTime 예약된 AudioSource.clip이 시작하는 시간을 설정합니다.
Stop AudioSource.clip 재생을 중지합니다.
UnPause ’AudioSource.clip’의 일시정지를 해제합니다.
PlayClipAtPoint 월드 공간의 특정 포지션에서 AudioSource.clip을 재생합니다.

AudioClip

Unity WebGL imports AudioClip files in the AAC Format, which is supported by most browsers. Unity WebGL supports the following AudioClip APIs:

프로퍼티 설명
length 초 단위의 AudioClip 길이입니다.
loadState AudioClip과 연결된 오디오 데이터의 현재 로드 상태를 반환합니다.
samples 샘플 단위의 AudioClip 길이입니다.
loadType 클립의 로드 타입입니다. 인스펙터에서 AudioClip 로드 타입을 설정할 수 있습니다.
메서드 설명 추가 정보
AudioClip.Create 지정된 이름과 길이의 AudioClip을 만듭니다. Unity WebGL partially supports AudioClip.Create. Browsers don’t support dynamic streaming, so to use AudioClip.Create, set the Stream to false.
AudioClip.SetData AudioSource.clip의 샘플 데이터를 설정합니다. Unity WebGL은 AudioClip.SetData를 부분적으로 지원합니다. 이 메서드는 AudioClip의 콘텐츠를 바꾸는 데만 사용할 수 있습니다. WebGL에서 Unity는 offsetSample 파라미터를 무시합니다.

Note: For audio clip support on Centos 7, make sure you’ve installed the ffmpeg package.

압축된 오디오

To use compressed audio with WebGL in Unity, set the AudioClip loadType to one of the following options:

압축 방식 설명 고려 사항
CompressedInMemory 디스크의 오디오를 압축하고, 애플리케이션 메모리에 로드한 후 압축된 상태를 유지합니다. Compressed audio can cause latency and is less precise when it comes to audio playback. However, compressed audio uses less memory in your application than decompressed audio. It’s best practise to use CompressedInMemory for audio that’s unaffected by precision for example, background music.
DecompressOnLoad CompressedInMemory와 마찬가지로 디스크의 오디오를 압축하고, 애플리케이션 메모리에 로드할 때 압축을 해제합니다. Decompressed audio uses a significant amount of memory compared to compressed audio but has lower latency and more audio flexibility. Use DecompressedOnLoad for audio that’s affected by precision (for example, character dialog or sound effects).

오디오 재생 및 브라우저 보안

보안상의 이유로 브라우저는 최종 사용자가 마우스 클릭, 터치 이벤트 또는 키 누름을 통해 애플리케이션 웹 페이지와 상호작용할 때까지 오디오 재생을 허용하지 않습니다. 메인 콘텐츠가 시작되기 전에 최종 사용자가 애플리케이션과 상호작용하고 오디오 재생을 시작할 수 있도록 로딩 화면을 사용하십시오.

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