Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

play sound in unity c#

using System.Collections;
using UnityEngine;

public class AudioManager : MonoBehaviour
{
    [SerializeField]
    private AudioSource sampleAudioSource = null;

    void Awake(){
		if (sampleAudioSource == null)
            Debug.LogError("AUDIO_MANAGER: sampleAudioSource is NULL");
    }

    public void PlaySampleSound()
	{
    	sampleAudioSource.Play();
    }
}
 
PREVIOUS NEXT
Tagged: #play #sound #unity
ADD COMMENT
Topic
Name
7+9 =