Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


AudioResource

Represents an audio generator asset that you can play through an AudioSource.
Read time 4 minutesLast updated 3 days ago

Definition

public abstract class AudioResource : Object

Remarks

Note: Audio generators don’t provide direct access to properties like
length
. However, if your audio generator is an AudioClip, you can access these properties through _clip. Other types of resources might not provide direct access to these properties because the resources are dynamic or the values might change every time you play the audio.
Additional Resources: AudioClip, AudioRandomContainer

Examples

using System.Collections;using UnityEngine;using UnityEngine.Audio; // Play an AudioClip, then an AudioResource, through an AudioSource.[RequireComponent(typeof(AudioSource))]public class ExampleClass : MonoBehaviour{ public AudioClip m_Clip; public AudioResource m_Resource; IEnumerator Start() { AudioSource audioSource = GetComponent<AudioSource>(); audioSource.resource = m_Clip; audioSource.Play(); yield return new WaitForSeconds(audioSource.clip.length); audioSource.resource = m_Resource; audioSource.Play(); }}

Inheritance

Inherited Members

Operators

Operator

Description

operator ==Compares two object references to see if they refer to the same object.
boolDetermines whether the object exists.
operator !=Compares if two objects refer to a different object.