Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

unity audio

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();
    }
}
Comment

Audio Unity

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
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: c# mvc get current directory 
Csharp :: string interpolation in c# 
Csharp :: how to access asp button of gridview 
Csharp :: c# static 
Csharp :: C# 1 minute delay 
Csharp :: Get Mac address of Device in Xamarin 
Csharp :: c# .equals vs == 
Csharp :: serenity frameword order column 
Csharp :: c# read excel file using epplus save to datatable 
Csharp :: Why Duplicate "..TargetFrameworkAttribute" c# assemblies created 
Csharp :: c sharp teleporting 
Csharp :: getelement video 
Csharp :: allow scroll with wheel mouse datagridview c# 
Csharp :: c# group array based on first character 
Csharp :: How to create a Blazor server-side application in command prompt 
Csharp :: unity reload active scene 
Csharp :: unity collision.impulse 
Csharp :: GetComponent<Button().onClick 
Csharp :: Convert integers to written numbers C# 
Csharp :: sto playing audiosource 
Csharp :: wpf keydown detect if control key is down 
Csharp :: trhow exception if is null c# 
Csharp :: caesar cipher in C# 
Csharp :: .net core copy file in folder to root 
Csharp :: c# list get last element 
Csharp :: run in wpf 
Csharp :: system.random reuses numbers 
Csharp :: fill dictionary c# 
Csharp :: serialize object to json 
Csharp :: ssml 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =