Version: 2023.2
public Audio.AudioResource resource ;

描述

The default AudioResource to play.

You can also use this property to set the AudioResource that plays next.

using UnityEngine;

[RequireComponent(typeof(AudioSource))] public class ExampleClass : MonoBehaviour { public AudioResource m_Resource;

public void PlayAudioResource() { AudioSource audioSource = GetComponent<AudioSource>(); audioSource.resource = m_Resource; audioSource.Play(); } }