void OnPress(GameObject go, bool isPress) { if (isPress) { if (go.name == "ButtonChat") { m_objChat.SetActive(true); m_objCancelChat.SetActive(false); m_IsStartChat = true; m_IsClickChat = true; m_IsCancelChat = false; m_chatTime = 10.0f; isChatClick = true; isSendChat = false; VoiceUtility.GetInstance().StartRecord(10); } } else { if (go.name == "ButtonChat") { Debug.Log("发送111"); if (!m_IsClickChat) { m_IsCancelChat = true; } SendChatSound(); } } }
void SendChatSound() { m_IsStartChat = false; m_objChat.SetActive(false); m_objCancelChat.SetActive(false); isChatClick = false; if (!m_IsCancelChat && !isSendChat) { isSendChat = true; Debug.Log("发送"); VoiceUtility.GetInstance().StopRecord(); string fileName = GameData.m_TableInfo.id.ToString() + "@" + Player.Instance.guid.ToString() + "@" + DateTime.Now.Ticks.ToString(); StartCoroutine(UploadMusic(VoiceUtility.GetInstance().GetLastRecordByteArray(), fileName, GameData.m_TableInfo.id.ToString())); } }
void Update() { if (m_IsStartChat && !isSendChat) { if (m_chatTime <= 0) { SendChatSound(); } else { m_chatTime -= Time.deltaTime; } m_ProgressImage.fillAmount = m_chatTime / 10.0f; m_SoundSize.fillAmount = (float)VoiceUtility.GetInstance().Volume * 1.28f; } }
// Use this for initialization void Awake() { _instance = this; }