protected override void onOpenUI(params object[] uiObjParams) { pressDown = false; release = false; close = false; _ProgressBar = transform.Find("Canvas/bar/wk_jdt1").GetComponent <Image>(); particleSystem_a = transform.Find("Canvas/bar/wk_lz4_a").GetComponent <ParticleSystem>(); particleSystem_a_1 = transform.Find("Canvas/bar/wk_lz4_a_1").GetComponent <ParticleSystem>(); _ProgressBar_Bt = transform.Find("Canvas/bar/wk_jdt"); _ProgressBar.fillAmount = 0f; if (uiObjParams.Length > 0) { updatePos = false; Vector2 uiPos = UICanvas.transform.InverseTransformPoint((Vector3)uiObjParams[0]); _ProgressBar.transform.parent.localPosition = new Vector3(uiPos.x, uiPos.y, 0); } if (uiObjParams.Length > 1) { updatePos = false; totalTime = (float)uiObjParams[1]; } else { totalTime = 1f; } _ProgressBar_Bt.gameObject.SetActive(false); _StartEvent.RegisterEvent(C_EnumEventChannel.Global, "UI_Press_Bar", (b) => { StartPress(); }); }
public void AddGetRecordStatusEvent(System.Action <bool> actionCallback = null) { C_DebugHelper.LogErrorFormat("SpeechRecognizeSystemEvent AddGetRecordStatusEvent start "); _ActionCallback = actionCallback; if (_GetRecordStatusEvent != null) { _GetRecordStatusEvent.UnregisterEvent(); } _GetRecordStatusEvent = null; _GetRecordStatusEvent = new C_Event(); _GetRecordStatusEvent.RegisterEvent(C_EnumEventChannel.Global, "ResponseRecordStatus", (status) => { _GetRecordStatusEvent.UnregisterEvent(); if (status != null) { C_DebugHelper.LogErrorFormat("ResponseRecordStatus is :" + status); string answer = "1"; if (answer.Equals(status[0])) { if (_ActionCallback != null) { _ActionCallback(true); } } else { Tips.Create("开启语音权限后,才可以继续使用噢!"); if (_ActionCallback != null) { _ActionCallback(false); } } } }); }
/// <summary> /// 超时 判断 默认 正确 /// </summary> void StopWithStartOverTimeCheck() { //没网 弹窗tips 不走腾讯云语音识别 等待超时 if (Application.internetReachability == NetworkReachability.NotReachable) { DelayCallback = DOVirtual.DelayedCall(2f, () => { ClearEvent(); DoScoreCallBack("100"); C_DebugHelper.Log("本轮语音识别无网络,默认正确!"); }); Tips.Create("语音识别异常,请切换网络后重试"); return; } //等待结果返回,5秒之后如果没有返回结果,则自动返回 DelayCallback = DOVirtual.DelayedCall(_DelayTime, () => { ClearEvent(); DoScoreCallBack("100"); C_DebugHelper.Log("当轮语音识别没有拿到结果,默认正确!请确定网络状况是否良好!"); }); float time = Time.time; //float timeScale = Time.timeScale; //DelayCallback.OnUpdate(() => //{ // if (Time.timeScale != timeScale) // { // C_DebugHelper.Log("TimeScale:" + Time.timeScale); // timeScale = Time.timeScale; // } // C_DebugHelper.Log("花费时间:" + (Time.time - time)); //}); if (_GetTecentWordEvent != null) { _GetTecentWordEvent.UnregisterEvent(); } _GetTecentWordEvent = null; _GetTecentWordEvent = new C_Event(); _GetTecentWordEvent.RegisterEvent(C_EnumEventChannel.Global, "ResponseRecord", (word) => { //停掉超时计算 //if (DelayCallback != null) //{ // DelayCallback.Kill(); // DelayCallback = null; //} ClearEvent(); GetTecentReslut((word == null || word.Length <= 0) ? "" : word[0].ToString()); }); _IsRecording = false; }
/// <summary> /// 开始录音,腾讯云 /// </summary> /// <param name="answer"></param> /// <param name="scoreCallback"></param> public void StartRecognizeAudioTecent(string word, System.Action <string> scoreCallback, ResultType type = ResultType.PickScore, int langType = 1, int speechType = 1, float recordDur = 3f, bool reward = false) { _ResultCallback = scoreCallback; _ResultType = type; if (recordDur <= 0) { DoScoreCallBack("0"); C_DebugHelper.LogError("您设置的录音时间过短,请重新确认!"); return; } #if UNITY_EDITOR DelayStop = DOVirtual.DelayedCall(recordDur, () => { StopWithStartOverTimeCheck(); }); return; #endif if (_GetRecordStatusEvent != null) { _GetRecordStatusEvent.UnregisterEvent(); } _GetRecordStatusEvent = null; _GetRecordStatusEvent = new C_Event(); _GetRecordStatusEvent.RegisterEvent(C_EnumEventChannel.Global, "ResponseRecordStatus", (status) => { _GetRecordStatusEvent.UnregisterEvent(); if (status != null) { string answer = "1"; if (answer.Equals(status[0])) { _IsRecording = true; } else { Tips.Create("开启语音权限后,才可以继续使用噢!"); } } #if !UNITY_IOS StartRecordAction(recordDur); #endif }); _AnswerWord = word; #if UNITY_IOS StartRecordAction(recordDur); #endif }
protected override void OnEnter() { CutsceneSequencePlayer.PauseCurrentCutscene(); _UnloadAndGameLoadState = UnloadAndGameLoadState.start; _SetActive = false; mStop = false; _SceneLoadEvent.RegisterEvent(C_EnumEventChannel.Global, "UnloadAndSceneLoadEvent", (object[] result) => { UnloadAndSceneLoadEvent(result); }); _MainSceneLoadEvent.RegisterEvent(C_EnumEventChannel.Global, "MainSceneLoadEvent", (object[] result) => { MainSceneLoadEvent(result); }); //if (string.IsNullOrEmpty(oldScenName)) //{ // C_DebugHelper.LogError("scenename is null"); // return; //} // Game_Minor.G_MinorCoreConfigData.SetGameCoreName(newScenName, NextStorySceneName); string sceneName = string.Empty; if (newApi) { // string sceneName = Game_Minor.G_MinorCoreConfigData.GetLoadNextSceneName(); if (string.IsNullOrEmpty(uiName)) { SceneLoadingMgr.GetInstance().PreUnloadSceneAndLoadNewSceneAsync(oldScenName, sceneName, loadConfig, () => { LoadOver(); }); } else { SceneLoadingMgr.GetInstance().PreUnloadSceneAndLoadNewSceneAsync(oldScenName, sceneName, loadConfig, () => { LoadOver(); }, uiName); } } else { if (string.IsNullOrEmpty(uiName)) { SceneLoadingMgr.GetInstance().PreUnloadSceneAndLoadNewSceneAsync(oldScenName, newScenName, loadConfig, () => { LoadOver(); }); } else { SceneLoadingMgr.GetInstance().PreUnloadSceneAndLoadNewSceneAsync(oldScenName, newScenName, loadConfig, () => { LoadOver(); }, uiName); } _ActiveSceneName = newScenName; } }