religion/Assets/Scripts/抽象/BGMPlayer.cs
Roman 5e29da1a25 任务:实装音乐,修复问题
1.实装每个场景的音乐,并安置好切歌功能

2.修复问题
(1.修复对话时能操作的问题
(2.修复开幕演出结束前玩家能够操作的问题
下班
(3.伊斯兰前置关掉怪太少了
(4.修复一边看板子一边走路会听不下来的问题
(5.调整了各怪物的攻击力和血量等信息
(6.调整各关卡图层,防止出现覆盖问题
(7.村右边空气墙忘加光滑材质
(8.敲钟音效太小声
(9.调整以撒粒子图层
(10.修改以撒Stage的转移点位置

*.不出意外的话,这就是最后的提交了
*.感慨万千,感慨万千
2021-12-28 17:08:26 +08:00

51 lines
1.3 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public class BGMPlayer : MonoBehaviour
{
// Start is called before the first frame update
private AudioSource audioPlayer;
private bool isSlowlyStopTheClip;
[Tooltip("请填入BGM切换时淡出原BGM的速度")]
public float fadeSpeed;
public AudioClip newBGM;
private float defulatVolume;
void Start()
{
DontDestroyOnLoad(gameObject);
audioPlayer = GetComponent<AudioSource>();
defulatVolume = audioPlayer.volume;
if(FindObjectsOfType<BGMPlayer>().Length > 1) Destroy(gameObject);
}
// Update is called once per frame
void Update()
{
if(isSlowlyStopTheClip)
{
audioPlayer.volume -= fadeSpeed*Time.deltaTime;
if(audioPlayer.volume.Equals(0f))
{
isSlowlyStopTheClip = false;
audioPlayer.clip = newBGM;
audioPlayer.volume = defulatVolume;
audioPlayer.Play();
}
}
//
Debug.Log(FindObjectOfType<PlayerInput>().currentActionMap);
//
}
public void ChangedTheBGM(AudioClip newBGM)
{
isSlowlyStopTheClip = true;
this.newBGM = newBGM;
}
}