26 lines
661 B
C#
26 lines
661 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Unity.VisualScripting;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
|
|
public class AudioTool
|
|
{
|
|
private static AudioSource _audioSource;
|
|
|
|
public static AudioSource AudioSource
|
|
{
|
|
get
|
|
{
|
|
if (_audioSource == null || _audioSource.IsDestroyed())
|
|
{
|
|
var audioGameObject = new GameObject("GlobalAudioSource");
|
|
_audioSource = audioGameObject.AddComponent<AudioSource>();
|
|
Object.DontDestroyOnLoad(audioGameObject);
|
|
}
|
|
return _audioSource;
|
|
}
|
|
}
|
|
}
|