蜗牛音效
This commit is contained in:
parent
f6d8f53f6c
commit
2a8c5b90dd
@ -1974,6 +1974,7 @@ GameObject:
|
|||||||
- component: {fileID: 278122027}
|
- component: {fileID: 278122027}
|
||||||
- component: {fileID: 278122026}
|
- component: {fileID: 278122026}
|
||||||
- component: {fileID: 278122030}
|
- component: {fileID: 278122030}
|
||||||
|
- component: {fileID: 278122031}
|
||||||
m_Layer: 5
|
m_Layer: 5
|
||||||
m_Name: Canvas
|
m_Name: Canvas
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
@ -2093,6 +2094,18 @@ MonoBehaviour:
|
|||||||
SellOpen: 0
|
SellOpen: 0
|
||||||
CreateTime:
|
CreateTime:
|
||||||
IsBuyGet: 0
|
IsBuyGet: 0
|
||||||
|
--- !u!114 &278122031
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 278122025}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 5c0828db7d2698a4793160e6324c81a9, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
--- !u!1 &278944241
|
--- !u!1 &278944241
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -3616,7 +3616,7 @@ RectTransform:
|
|||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0, y: 1}
|
m_AnchorMin: {x: 0, y: 1}
|
||||||
m_AnchorMax: {x: 0, y: 1}
|
m_AnchorMax: {x: 0, y: 1}
|
||||||
m_AnchoredPosition: {x: 686, y: -1387.5}
|
m_AnchoredPosition: {x: 548.1, y: -1387.5}
|
||||||
m_SizeDelta: {x: 1018, y: 0}
|
m_SizeDelta: {x: 1018, y: 0}
|
||||||
m_Pivot: {x: 0.5, y: 0.5}
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
--- !u!114 &1071890038
|
--- !u!114 &1071890038
|
||||||
@ -3780,6 +3780,156 @@ MonoBehaviour:
|
|||||||
m_FlexibleWidth: -1
|
m_FlexibleWidth: -1
|
||||||
m_FlexibleHeight: -1
|
m_FlexibleHeight: -1
|
||||||
m_LayoutPriority: 1
|
m_LayoutPriority: 1
|
||||||
|
--- !u!1 &1102437595
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 1102437598}
|
||||||
|
- component: {fileID: 1102437597}
|
||||||
|
- component: {fileID: 1102437596}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: MusicManeger
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!82 &1102437596
|
||||||
|
AudioSource:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1102437595}
|
||||||
|
m_Enabled: 1
|
||||||
|
serializedVersion: 4
|
||||||
|
OutputAudioMixerGroup: {fileID: 0}
|
||||||
|
m_audioClip: {fileID: 0}
|
||||||
|
m_PlayOnAwake: 0
|
||||||
|
m_Volume: 1
|
||||||
|
m_Pitch: 1
|
||||||
|
Loop: 1
|
||||||
|
Mute: 0
|
||||||
|
Spatialize: 0
|
||||||
|
SpatializePostEffects: 0
|
||||||
|
Priority: 128
|
||||||
|
DopplerLevel: 1
|
||||||
|
MinDistance: 1
|
||||||
|
MaxDistance: 500
|
||||||
|
Pan2D: 0
|
||||||
|
rolloffMode: 0
|
||||||
|
BypassEffects: 0
|
||||||
|
BypassListenerEffects: 0
|
||||||
|
BypassReverbZones: 0
|
||||||
|
rolloffCustomCurve:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 1
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 1
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
panLevelCustomCurve:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
spreadCustomCurve:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
reverbZoneMixCustomCurve:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 1
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
--- !u!114 &1102437597
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1102437595}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 7ca9a1b6cc8a74c4a8f1cf7738bcda5c, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
audioSource: {fileID: 1102437596}
|
||||||
|
BGMaudioSource: {fileID: 0}
|
||||||
|
buttonClickClip: {fileID: 8300000, guid: b9a93b2211568a64d8a3484b0a15bb7a, type: 3}
|
||||||
|
BGMClickClip_main: {fileID: 8300000, guid: ae52ddaa7f7d2d347957dd569a285bb5, type: 3}
|
||||||
|
BGMClickClip_Time: {fileID: 8300000, guid: 7b710e9df51388b478209c3e8dffa8c3, type: 3}
|
||||||
|
ClickClip_fight: {fileID: 8300000, guid: c27de3f87311955479c8fbeefbe455ec, type: 3}
|
||||||
|
ClickClip_doorOpen: {fileID: 8300000, guid: 1acc9485c110cbb47bd93570e1109b98, type: 3}
|
||||||
|
ClickClip_attack: {fileID: 8300000, guid: bb82cb1edbf45b344bc556479bf0535f, type: 3}
|
||||||
|
ClickClip_Paoxiao: {fileID: 8300000, guid: cd23215095141fd4886ef4130a6344e3, type: 3}
|
||||||
|
--- !u!4 &1102437598
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1102437595}
|
||||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_ConstrainProportionsScale: 0
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 0}
|
||||||
|
m_RootOrder: 4
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!1 &1166404693
|
--- !u!1 &1166404693
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -37,6 +37,7 @@ public class AllHouseContro : MonoBehaviour
|
|||||||
|
|
||||||
public bool IsLoadIn;//是否已经进入游戏
|
public bool IsLoadIn;//是否已经进入游戏
|
||||||
public bool IsHideLoadPanel;//是否关闭加载页面
|
public bool IsHideLoadPanel;//是否关闭加载页面
|
||||||
|
public bool IsPlayTimeMusic;//是否播放倒计时击杀3-2-1
|
||||||
|
|
||||||
public List<int> KillNos;//击杀房间列表
|
public List<int> KillNos;//击杀房间列表
|
||||||
|
|
||||||
@ -44,6 +45,7 @@ public class AllHouseContro : MonoBehaviour
|
|||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
async void Start()
|
async void Start()
|
||||||
{
|
{
|
||||||
|
UIBtnMusic.instance.PlayBGMClickSound(UIBtnMusic.instance.BGMClickClip_Time);
|
||||||
battleRoyaleGameDetails();
|
battleRoyaleGameDetails();
|
||||||
GetInfo516();
|
GetInfo516();
|
||||||
GetInfo517();
|
GetInfo517();
|
||||||
@ -267,6 +269,7 @@ public class AllHouseContro : MonoBehaviour
|
|||||||
|
|
||||||
ListPanel.instance.UpdatePanels();
|
ListPanel.instance.UpdatePanels();
|
||||||
PlayerInfo.instance.AllBetCoins = 0;//投注归0
|
PlayerInfo.instance.AllBetCoins = 0;//投注归0
|
||||||
|
IsPlayTimeMusic = false;
|
||||||
}
|
}
|
||||||
else if (serverResponse.data.carrySeconds < 45){
|
else if (serverResponse.data.carrySeconds < 45){
|
||||||
|
|
||||||
@ -279,16 +282,24 @@ public class AllHouseContro : MonoBehaviour
|
|||||||
|
|
||||||
//ClearBoosHouseId();//清空boos房间号
|
//ClearBoosHouseId();//清空boos房间号
|
||||||
ControAllDoorOpen();
|
ControAllDoorOpen();
|
||||||
|
if (serverResponse.data.carrySeconds >= 42)
|
||||||
|
{
|
||||||
|
if (!IsPlayTimeMusic && IsHideLoadPanel)//判断是否已经播放倒计时音乐,并且加载界面已经关闭
|
||||||
|
{
|
||||||
|
UIBtnMusic.instance.PlayClickSound(UIBtnMusic.instance.ClickClip_fight);
|
||||||
|
IsPlayTimeMusic = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
text.GetComponentInChildren<TextMeshProUGUI>().text = (45 - serverResponse.data.carrySeconds).ToString();
|
text.GetComponentInChildren<TextMeshProUGUI>().text = (45 - serverResponse.data.carrySeconds).ToString();
|
||||||
detailsText.GetComponentInChildren<Text>().text = "秒后霸主出现";
|
detailsText.GetComponentInChildren<Text>().text = "秒后霸主出现";
|
||||||
await Task.Delay(1000);
|
await Task.Delay(1000);
|
||||||
text.GetComponentInChildren<TextMeshProUGUI>().text = (45 - serverResponse.data.carrySeconds - 1).ToString();
|
text.GetComponentInChildren<TextMeshProUGUI>().text = (45 - serverResponse.data.carrySeconds - 1).ToString();
|
||||||
|
|
||||||
|
|
||||||
allother.startIEmove();//生成其他蜗牛
|
allother.startIEmove();//生成其他蜗牛
|
||||||
//if (!HaveallotherMove)
|
//if (!HaveallotherMove)
|
||||||
//{
|
//{
|
||||||
// //StartCoroutine(allother.IECreateWoniu());
|
//StartCoroutine(allother.IECreateWoniu());
|
||||||
|
|
||||||
|
|
||||||
// HaveallotherMove = true;
|
// HaveallotherMove = true;
|
||||||
@ -305,9 +316,13 @@ public class AllHouseContro : MonoBehaviour
|
|||||||
detailsText.GetComponentInChildren<Text>().text = "";//霸主出现
|
detailsText.GetComponentInChildren<Text>().text = "";//霸主出现
|
||||||
if (!is_jisha){
|
if (!is_jisha){
|
||||||
is_jisha = true;
|
is_jisha = true;
|
||||||
|
if (IsHideLoadPanel)
|
||||||
|
{
|
||||||
|
UIBtnMusic.instance.PlayClickSound(UIBtnMusic.instance.ClickClip_Paoxiao);
|
||||||
|
}
|
||||||
|
|
||||||
warnPanel.ShowPanel();
|
warnPanel.ShowPanel();
|
||||||
await Task.Delay(3000);
|
await Task.Delay(2000);
|
||||||
warnPanel.HidePanel();
|
warnPanel.HidePanel();
|
||||||
|
|
||||||
response = await web.SendRequest(web.URL + "/snail/gameEscape/queryKill", "POST", JsonUtility.ToJson(body), Global.global.CreateHeaders());
|
response = await web.SendRequest(web.URL + "/snail/gameEscape/queryKill", "POST", JsonUtility.ToJson(body), Global.global.CreateHeaders());
|
||||||
@ -361,7 +376,7 @@ public class AllHouseContro : MonoBehaviour
|
|||||||
else if (serverResponse.data.carrySeconds > 56) {
|
else if (serverResponse.data.carrySeconds > 56) {
|
||||||
|
|
||||||
|
|
||||||
ClearBoosHouseId();////
|
ClearBoosHouseId();
|
||||||
text.GetComponentInChildren<TextMeshProUGUI>().text = "";
|
text.GetComponentInChildren<TextMeshProUGUI>().text = "";
|
||||||
detailsText.GetComponentInChildren<Text>().text = "";//结算
|
detailsText.GetComponentInChildren<Text>().text = "";//结算
|
||||||
|
|
||||||
@ -549,6 +564,11 @@ public class AllHouseContro : MonoBehaviour
|
|||||||
}
|
}
|
||||||
public void ControOneDoorOpen(int id,System.Action onComplete = null)
|
public void ControOneDoorOpen(int id,System.Action onComplete = null)
|
||||||
{
|
{
|
||||||
|
if (IsHideLoadPanel)
|
||||||
|
{
|
||||||
|
UIBtnMusic.instance.PlayClickSound(UIBtnMusic.instance.ClickClip_doorOpen);
|
||||||
|
}
|
||||||
|
|
||||||
Tools.MoveUpOrDwon(HouseBtnList[id-1].door, 270,onComplete);
|
Tools.MoveUpOrDwon(HouseBtnList[id-1].door, 270,onComplete);
|
||||||
HouseBtnList[id-1].DoorIsOpen = true;
|
HouseBtnList[id-1].DoorIsOpen = true;
|
||||||
}
|
}
|
||||||
@ -561,8 +581,9 @@ public class AllHouseContro : MonoBehaviour
|
|||||||
|
|
||||||
public void OpenBoosDoor(HouseBtn boosHouse)
|
public void OpenBoosDoor(HouseBtn boosHouse)
|
||||||
{
|
{
|
||||||
if (!boosHouse.DoorIsOpen)
|
if (!boosHouse.DoorIsOpen&&IsHideLoadPanel)
|
||||||
{
|
{
|
||||||
|
UIBtnMusic.instance.PlayClickSound(UIBtnMusic.instance.ClickClip_doorOpen);
|
||||||
Tools.MoveUpOrDwon(boosHouse.door, 270);
|
Tools.MoveUpOrDwon(boosHouse.door, 270);
|
||||||
boosHouse.DoorIsOpen = true;
|
boosHouse.DoorIsOpen = true;
|
||||||
}
|
}
|
||||||
|
@ -238,7 +238,7 @@ public class PlayerMove : MonoBehaviour
|
|||||||
{
|
{
|
||||||
if (IsBoos)
|
if (IsBoos)
|
||||||
{
|
{
|
||||||
duration = 2f;
|
duration = 3f;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -370,7 +370,13 @@ public class PlayerMove : MonoBehaviour
|
|||||||
IEnumerator BoosAttack()
|
IEnumerator BoosAttack()
|
||||||
{
|
{
|
||||||
GetComponent<BossContro>().BossAni.SetInteger("State", 2);
|
GetComponent<BossContro>().BossAni.SetInteger("State", 2);
|
||||||
yield return new WaitForSeconds(2.1f);
|
yield return new WaitForSeconds(1f);
|
||||||
|
if (allHouseContro.IsHideLoadPanel)
|
||||||
|
{
|
||||||
|
UIBtnMusic.instance.PlayClickSound(UIBtnMusic.instance.ClickClip_attack);
|
||||||
|
}
|
||||||
|
|
||||||
|
yield return new WaitForSeconds(1.1f);
|
||||||
GetComponent<BossContro>().BossAni.SetInteger("State", 0);
|
GetComponent<BossContro>().BossAni.SetInteger("State", 0);
|
||||||
if (allHouseContro.KillNos.Count>0)
|
if (allHouseContro.KillNos.Count>0)
|
||||||
{
|
{
|
||||||
|
@ -95,7 +95,7 @@ public class logoPanel : Base
|
|||||||
//}
|
//}
|
||||||
loginbody body = new loginbody
|
loginbody body = new loginbody
|
||||||
{
|
{
|
||||||
userName = "541236987",
|
userName = "15151658596",
|
||||||
//password = "123456",
|
//password = "123456",
|
||||||
verifyCode = 111111
|
verifyCode = 111111
|
||||||
};
|
};
|
||||||
|
22
TheStrongestSnail/Assets/Scripts/Scene_main/main_BGM.cs
Normal file
22
TheStrongestSnail/Assets/Scripts/Scene_main/main_BGM.cs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class main_BGM : MonoBehaviour
|
||||||
|
{
|
||||||
|
// Start is called before the first frame update
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
if (UIBtnMusic.instance.audioSource.clip!= UIBtnMusic.instance.BGMClickClip_main)//如果不是主界面音乐则改为主界面音乐
|
||||||
|
{
|
||||||
|
UIBtnMusic.instance.PlayBGMClickSound(UIBtnMusic.instance.BGMClickClip_main);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update is called once per frame
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
11
TheStrongestSnail/Assets/Scripts/Scene_main/main_BGM.cs.meta
Normal file
11
TheStrongestSnail/Assets/Scripts/Scene_main/main_BGM.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5c0828db7d2698a4793160e6324c81a9
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
70
TheStrongestSnail/Assets/Scripts/UIBtnMusic.cs
Normal file
70
TheStrongestSnail/Assets/Scripts/UIBtnMusic.cs
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
using UnityEngine.SceneManagement;
|
||||||
|
|
||||||
|
public class UIBtnMusic : MonoBehaviour
|
||||||
|
{
|
||||||
|
public static UIBtnMusic instance;
|
||||||
|
public AudioSource audioSource; // 音效播放器
|
||||||
|
public AudioSource BGMaudioSource;//背景音效
|
||||||
|
public AudioClip buttonClickClip; // 按钮点击音效
|
||||||
|
public AudioClip BGMClickClip_main;//主场景
|
||||||
|
public AudioClip BGMClickClip_Time;//大逃杀倒计时
|
||||||
|
public AudioClip ClickClip_fight;//大逃杀击杀倒计时
|
||||||
|
public AudioClip ClickClip_doorOpen;//开门
|
||||||
|
public AudioClip ClickClip_attack;//攻击
|
||||||
|
public AudioClip ClickClip_Paoxiao;//攻击
|
||||||
|
private void Start()
|
||||||
|
{
|
||||||
|
instance = this;
|
||||||
|
// 保持音效管理器不被销毁
|
||||||
|
DontDestroyOnLoad(gameObject);
|
||||||
|
|
||||||
|
// 给场景中所有按钮添加音效
|
||||||
|
AddButtonSoundEffects();
|
||||||
|
|
||||||
|
// 监听场景加载事件
|
||||||
|
SceneManager.sceneLoaded += OnSceneLoaded;
|
||||||
|
PlayBGMClickSound(BGMClickClip_main);//背景播放
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
|
||||||
|
{
|
||||||
|
// 每次切换到新场景时,都为所有按钮添加音效
|
||||||
|
AddButtonSoundEffects();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddButtonSoundEffects()
|
||||||
|
{
|
||||||
|
Button[] buttons = FindObjectsOfType<Button>();
|
||||||
|
foreach (Button button in buttons)
|
||||||
|
{
|
||||||
|
button.onClick.RemoveListener(OnButtonClick); // 确保没有重复添加监听器
|
||||||
|
button.onClick.AddListener(OnButtonClick);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnButtonClick()
|
||||||
|
{
|
||||||
|
PlayButtonClickSound();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PlayButtonClickSound()
|
||||||
|
{
|
||||||
|
if (audioSource && buttonClickClip)
|
||||||
|
{
|
||||||
|
audioSource.PlayOneShot(buttonClickClip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void PlayBGMClickSound(AudioClip audioClip)//背景播放
|
||||||
|
{
|
||||||
|
audioSource.clip = audioClip;
|
||||||
|
audioSource.Play();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void PlayClickSound(AudioClip audioClip)//音效播放
|
||||||
|
{
|
||||||
|
audioSource.PlayOneShot(audioClip);
|
||||||
|
}
|
||||||
|
}
|
11
TheStrongestSnail/Assets/Scripts/UIBtnMusic.cs.meta
Normal file
11
TheStrongestSnail/Assets/Scripts/UIBtnMusic.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 7ca9a1b6cc8a74c4a8f1cf7738bcda5c
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Loading…
Reference in New Issue
Block a user