You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.3 KiB
55 lines
1.3 KiB
using System; |
|
using System.Collections; |
|
using System.Collections.Generic; |
|
using UnityEngine; |
|
using UnityEngine.UI; |
|
|
|
/// <summary> |
|
/// 聊天频道按钮 |
|
/// </summary> |
|
public class ChatChannelButton : MonoBehaviour |
|
{ |
|
//聊天面板 |
|
public ChatPanel Panel; |
|
private Toggle toggle; |
|
private Text text; |
|
private int channelID; |
|
private void Awake() |
|
{ |
|
toggle = GetComponent<Toggle>(); |
|
text = GetComponentInChildren<Text>(); |
|
channelID = int.Parse(gameObject.name.ToString()); |
|
} |
|
private void OnEnable() |
|
{ |
|
toggle.onValueChanged.AddListener(OnValueChanged); |
|
} |
|
|
|
private void OnDisable() |
|
{ |
|
toggle.onValueChanged.RemoveListener(OnValueChanged); |
|
} |
|
/// <summary> |
|
/// |
|
/// </summary> |
|
/// <param name="arg0"></param> |
|
private void OnValueChanged(bool arg0) |
|
{ |
|
|
|
if (arg0) |
|
{ |
|
// 停止当前频道在播放的音频 |
|
AudioManager.Instance.Stop(ChatType.PublicChat.ToString()); |
|
text.color = Color.white; |
|
//申请离开当前频道 |
|
ChatManager.Instance.SendLeavePublicChatChannel(); |
|
ChatManager.Instance.joinChannelID = channelID; |
|
} |
|
else |
|
{ |
|
text.color = new Color32(140, 166, 255, 255); |
|
} |
|
} |
|
|
|
|
|
}
|
|
|