Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

pause 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

audio source pause unity


using UnityEngine;[RequireComponent(typeof(AudioSource))]
public audioSource audioSource  = GetComponent<AudioSource>();

void Start();{
	audioSource.Pause();
}

Comment

PREVIOUS NEXT
Code Example
Csharp :: unity how to get the first word from string 
Csharp :: rb.addforce c# 
Csharp :: merge point 
Csharp :: fluentassertions force exceptions 
Csharp :: c# writeline list 
Csharp :: Compare trees 
Csharp :: how to change loaded scene in unity 
Csharp :: import time C# 
Csharp :: how to map datatable to list in c# 
Csharp :: get query string parameter from string value c# 
Csharp :: dotnet ef migrations to folder 
Csharp :: using serial port in c# 
Csharp :: .net core check if user is logged in 
Csharp :: how to run code without a gameobject unity 
Csharp :: c# find duplicates in list of strings 
Csharp :: how to copy last element in list c# 
Csharp :: Razor foreach loop 
Csharp :: change sprite of a sprite unity 
Csharp :: c# get set value 
Csharp :: how to make a mouse down condition in unity 
Csharp :: listview item click c# 
Csharp :: c# array to list 
Csharp :: get layermask from gameobject layer unity 
Csharp :: log to console c# unity 
Csharp :: c# color hex 
Csharp :: if in dictionary c# 
Csharp :: c# winforms textbox select text 
Csharp :: how to add to a list c# 
Csharp :: c# convert int to string 
Csharp :: gameobject on click unity 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =