Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

unity c# audio source

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

unity audio source

m_MyAudioSource.Play();
Comment

access audio source from gameobject unity

AudioSource source1 = GameObject.FindGameObjectWithTag("GameObject1").GetComponent<AudioSource>();

GetComponent<AudioSource>().clip = source1.clip;
Comment

PREVIOUS NEXT
Code Example
Csharp :: onmousedown() not working unity 
Csharp :: c# fileupload example 
Csharp :: c# get last array element 
Csharp :: how to return a value in c# 
Csharp :: remove from list based on condition c# 
Csharp :: c# while loop 
Csharp :: c# null conditional 
Csharp :: c# array.reduce 
Csharp :: read all lines split C# 
Csharp :: How to make a simple console select screen using C# ReadKey 
Csharp :: how to change text in richtextbox wpf 
Csharp :: c# sharepoint get users from column 
Csharp :: C# one line method 
Csharp :: superscript list 
Csharp :: null-conditional operators c# 
Csharp :: C# traverseall elements in class property 
Csharp :: spin with rigidbody 2d unity 
Csharp :: interop C# save as and replace 
Csharp :: get gameobject active state 
Csharp :: Convert integers to written numbers C# 
Csharp :: curl rest api keycloak 
Csharp :: wpf get name of clicked element 
Csharp :: unity c# image invisible 
Csharp :: Count the Number of Duplicate Characters 
Csharp :: c# get out of for loop 
Csharp :: how to check if button is pressed unity 
Csharp :: base c# 
Csharp :: long string c# 
Csharp :: c# method declaration 
Csharp :: c# return values 
ADD CONTENT
Topic
Content
Source link
Name
4+4 =