private void OnPrassVoice(GameObject sender, bool isPrass) { #if UNITY_ANDROID if (!XyskAndroidAPI.hasMicrophoneAuth() && isPrass) { PopText.Instance.Show(LanguageManager.instance.GetValue("microphoneforbidden"), PopText.WarningType.WT_Warning); return; } #elif UNITY_IOS if (!XyskIOSAPI.HasMicrophoneAuth() && isPrass) { PopText.Instance.Show(LanguageManager.instance.GetValue("microphoneforbidden"), PopText.WarningType.WT_Warning); return; } #endif if (Microphone.devices.Length == 0) { ClientLog.Instance.Log("No Record Device!"); return; } if (isPrass) { isCanel = false; ischaoshi = false; PrassTime = Time.realtimeSinceStartup; istargetPrass = true; ChatSystem.StartRecord(); yuyinTips.SetActive(true); } else { istargetPrass = false; yuyinTips.SetActive(false); if (ischaoshi) { return; } float tm = Time.realtimeSinceStartup - PrassTime; ChatSystem.StopRecord(); if (tm < 1) { PopText.Instance.Show(LanguageManager.instance.GetValue("chatVeTime")); } else { if (isCanel) { return; } if (ChatSystem.AsyncGetCallBack == null) { ChatSystem.AsyncGetCallBack = delegate(byte[] datas) { audioChat_ = new COM_Chat(); audioChat_.audio_ = datas; audioChat_.isAudio_ = true; audioChat_.audioTime_ = (int)tm; //int le = Mathf.RoundToInt(ChatSystem.GetClipLength(audioChat_.audio_)); ChatSystem.SendToServer(_SendChatKind, "", "", audioChat_.audio_, audioChat_.audioTime_); ClientLog.Instance.Log("audioChat_.audio_=====" + audioChat_.audio_.Length); audioChat_ = null; }; ChatSystem.AsyncGet(); } } } }
void Update() { if (istargetPrass) { if (Input.GetMouseButtonDown(0)) { mousePosition_Y = Input.mousePosition.y; } if (Input.GetMouseButton(0)) { if (Input.mousePosition.y - mousePosition_Y > 80) { isCanel = true; } } tt = Mathf.Max(0, maxTime - (Time.realtimeSinceStartup - PrassTime)); if (tt == 0) { yuyinTips.SetActive(false); int audiolen = Mathf.RoundToInt(Time.realtimeSinceStartup - PrassTime); ChatSystem.StopRecord(); if (ChatSystem.AsyncGetCallBack == null) { ChatSystem.AsyncGetCallBack = delegate(byte[] datas) { audioChat_ = new COM_Chat(); audioChat_.audio_ = datas; audioChat_.isAudio_ = true; audioChat_.audioTime_ = audiolen; //int le = Mathf.RoundToInt(ChatSystem.GetClipLength(audioChat_.audio_)); ChatSystem.SendToServer(_SendChatKind, "", "", audioChat_.audio_, audioChat_.audioTime_); ClientLog.Instance.Log("audioChat_.audio_====+++++=" + audioChat_.audio_.Length); ischaoshi = true; istargetPrass = false; audioChat_ = null; }; ChatSystem.AsyncGet(); } } } if (!_IsDirty) { return; } if (!ChatSystem.GetChannelInfo(_OpenChannels, ref _ChannelInfo, ref index)) { return; } if (_ChannelInfo.Count == 0) { //木有 _CachedFreeGridItem(0); _IsDirty = false; return; } for (int i = 0; i < _ChannelInfo.Count; ++i) { _MakedGridItem(i, _ChannelInfo[i]); //链表下标访问 是不是很 } _CachedFreeGridItem(_ChannelInfo.Count); //清理多余物件 // GlobalInstanceFunction.Instance.Invoke(() => // { cGrid.Reposition(); if (!isLock) { _Sb.value = 1; } // }, 2); _IsDirty = false; }
private void OnPrassVoice(GameObject sender, bool isPrass) { #if UNITY_ANDROID if (!XyskAndroidAPI.hasMicrophoneAuth()) { PopText.Instance.Show(LanguageManager.instance.GetValue("microphoneforbidden"), PopText.WarningType.WT_Warning); return; } #elif UNITY_IOS if (!XyskIOSAPI.HasMicrophoneAuth() && isPrass) { PopText.Instance.Show(LanguageManager.instance.GetValue("microphoneforbidden"), PopText.WarningType.WT_Warning); return; } #endif if (Microphone.devices.Length == 0) { ClientLog.Instance.Log("No Record Device!"); return; } if (isPrass) { isCanel = false; ischaoshi = false; PrassTime = Time.realtimeSinceStartup; istargetPrass = true; ChatSystem.StartRecord(); yuyinTips.SetActive(true); } else { istargetPrass = false; yuyinTips.SetActive(false); chat_com = new COM_Chat(); if (ischaoshi) { return; } float tm = Time.realtimeSinceStartup - PrassTime; if (tm < 1) { PopText.Instance.Show(LanguageManager.instance.GetValue("chatVeTime")); } else { if (isCanel) { return; } ChatSystem.StopRecord(); if (ChatSystem.AsyncGetCallBack == null) { ChatSystem.AsyncGetCallBack = delegate(byte[] datas) { chat_com.audio_ = datas; NetConnection.Instance.queryOnlinePlayerbyName(_selectFriend.name_); }; ChatSystem.AsyncGet(); } //ChatSystem.GetClip(ref chat_com.audio_); //NetConnection.Instance.queryOnlinePlayerbyName (_selectFriend.name_); //ChatSystem.SendToServer(_SendChatKind,"","",chat_com.audio_); } } }