Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

stop audio unity

using System.Collections;
using System.Collections.Generic;
using UnityEngine;


public AudioSource MyAudioSource; //put your object in inspector that have the audio


void Update(){


if (Input.GetKeyDown(KeyCode.Escape)) //When press ESC to pause the game
        {
            if (Time.timeScale == 0)
            {
                MyAudioSource.Stop();
            }
            else
            {
                MyAudioSource.Play();
            }
        }
        
        }
Comment

unity stop all audio

// unity stop all sound by yasin
 private var allAudioSources : AudioSource[];
  
 function Awake() {
     allAudioSources = FindObjectsOfType(AudioSource) as AudioSource[];
 }
  
 function StopAllAudio() {
     for(var audioS : AudioSource in allAudioSources) {
         audioS.Stop();
     }
 }
Comment

stop sound in unity

audioSource.Play();//Start playing
audioSource.Stop();//Stop playing
Comment

PREVIOUS NEXT
Code Example
Csharp :: print in c# 
Csharp :: c# check if string is empty 
Csharp :: c# boilerplate 
Csharp :: c# loop datatable rows 
Csharp :: round corners of textbox wpf 
Csharp :: c# get last character of string 
Csharp :: unity movetowards 
Csharp :: unity why is there no transform.left 
Csharp :: unity Protected 
Csharp :: unity instantiate empty gameobject 
Csharp :: unity 2d detect click on sprite 
Csharp :: asp core asp for not working 
Csharp :: c# get bytes from string 
Csharp :: unity scriptable object 
Csharp :: unity rotate gameobject 90 degrees 
Csharp :: c# format decimal as currency 
Csharp :: get all files in all subdirectories c# 
Csharp :: get host ip address asp.net core 
Csharp :: how to move your character in unity 2d game 
Csharp :: unity projectile spread 
Csharp :: unity left mouse button 
Csharp :: unity c# redirect to webiste 
Csharp :: read configuration workerservice 
Csharp :: C# infinite clock coroutine loop 
Csharp :: unity invisible cube 
Csharp :: Request.ServerVariables["HTTP_X_FORWARDED_FOR"] get only one ipaddress 
Csharp :: which gas is at anode 
Csharp :: Codewars Multiply 
Csharp :: monogame fullscreen 
Csharp :: valid url in .net 
ADD CONTENT
Topic
Content
Source link
Name
9+4 =