-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAudioManager.cs
More file actions
45 lines (37 loc) · 902 Bytes
/
AudioManager.cs
File metadata and controls
45 lines (37 loc) · 902 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AudioManager : MonoBehaviour
{
public static AudioManager Instance;
private AudioSource player;
public AudioClip jump;
public AudioClip die1;
public AudioClip die2;
// Start is called before the first frame update
void Start()
{
Instance = this;
player = GetComponent<AudioSource>();
}
//播放跳跃音效
public void PlayJump()
{
player.PlayOneShot(jump);
}
//播放死亡音效
public void PlayDie()
{
//BGM停止
player.Stop();
//播放死亡音效
player.PlayOneShot(die1);
//1s后调用PlayDie2
Invoke("PlayDie2", 1f);
}
//后续音效
void PlayDie2()
{
player.PlayOneShot(die2);
}
}