Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

play sound in sequence unity

public class PlayNotes : MonoBehaviour
{
    public AudioSource adSource;
    public AudioClip[] adClips;

    // Index of the currently played sound
    private int index;

    public void PlayNote()
    {  
        // Play current sound
        // I would rather use PlayOneShot in order to allow multiple concurrent sounds
        adSource.PlayOneShot(adClips[index]);

        // Increase the index, wrap around if reached end of array
        index = (index + 1) % adClips.Length;
    }  
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: StringFormat C# 
Csharp :: how to compare time strings in c# 
Csharp :: .net core login redirect loop 
Csharp :: array sum c# 
Csharp :: c# bool list count true 
Csharp :: gql query with parameters 
Csharp :: escape chars for regex c# 
Csharp :: Generic Stack 
Csharp :: c# string across multiple lines 
Csharp :: ssis sql query in script task 
Csharp :: how to create class in c# 
Csharp :: Using Linq to get the last N elements of a collection? C# 
Csharp :: by value by reference c# 
Csharp :: crud operation in asp.net 
Csharp :: c# how to initialize an array 
Csharp :: datatable in c# 
Csharp :: symfony debug bar 
Csharp :: FiveM pc key code 
Csharp :: add rotation 
Csharp :: C# ToCsv Extension Method 
Csharp :: How to build a rest component with very long process 
Csharp :: c# compare months 
Csharp :: remove loading bars devexpress on callback 
Csharp :: gcm_sender_id convert text 
Csharp :: join where order by .net framework 
Csharp :: Make Enemy follow and rotate towards target in Unity 
Csharp :: .net objects 
Csharp :: how to perform drop down when click on combobox in c# net 
Csharp :: c# add field to expando object 
Csharp :: mpeg get video size 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =