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();
}
}
m_MyAudioSource.Play();
private AudioSource audio; // Get the audio
void Start()
{
audio = GetComponent<AudioSource>(); // Get the component(Add the component first and don't forget to atach the audio)
PlayAudio(); // Call the PlayAudio Function
}
void PlayAudio()
{
audio.Play(); // Play the audio use Stop() to stop the audio
}
Code Example |
---|
Csharp :: c# append array |
Csharp :: roman to int |
Csharp :: c# dictionary values to list |
Csharp :: billboard canvas unity |
Csharp :: check if file exist c# |
Csharp :: string to datetime c# |
Csharp :: recursive reverse linked list |
Csharp :: Squares of a Sorted Array |
Csharp :: c# see if list contains any duplicates |
Csharp :: 1 line if c# |
Csharp :: single line and multiline comments in c# |
Csharp :: list search c# |
Csharp :: C# monogodb |
Csharp :: lcm of numbers |
Csharp :: c# readline char |
Csharp :: unity gui text |
Csharp :: unity text color |
Csharp :: asp.net mvc image upload |
Csharp :: ternary operator c# |
Csharp :: c# enum |
Csharp :: c# is odd number |
Csharp :: text read C# |
Csharp :: dynamic group by expression C# |
Csharp :: unity toint |
Csharp :: pyautopgui erros |
Csharp :: how to make pc bsod C# |
Csharp :: meaning of ??= in c# |
Csharp :: web page search c# |
Csharp :: replace multiple characters in string c# |
Csharp :: how to reload app.config file at runtime in c# |