diff --git a/Assets/Scripts/Actions/AnimationAction.cs b/Assets/Scripts/Actions/AnimationAction.cs index e3c9f60c..fd96f1ee 100644 --- a/Assets/Scripts/Actions/AnimationAction.cs +++ b/Assets/Scripts/Actions/AnimationAction.cs @@ -65,55 +65,61 @@ namespace QFramework if (obj.activeSelf == false) { Debug.LogError(obj.name + "当前是隐藏状态"); + this.Finish(); } - try + else { - anim = obj.GetComponent(); - - if (string.IsNullOrEmpty(frame) == false && frame != "-1") + try { - int curFrame = 0; - int.TryParse(frame, out curFrame); - anim.clip = anim[animName].clip; - anim[animName].time = curFrame / anim.clip.frameRate; - anim[animName].speed = 0; - anim.Play(animName); - this.Finish(); - } - else - { - float curSpeed = 1; - if (string.IsNullOrEmpty(speed) == false) - { - float.TryParse(speed, out curSpeed); - } + anim = obj.GetComponent(); - if (curSpeed < 0) + if (string.IsNullOrEmpty(frame) == false && frame != "-1") { + int curFrame = 0; + int.TryParse(frame, out curFrame); + anim.clip = anim[animName].clip; + anim[animName].time = curFrame / anim.clip.frameRate; + anim[animName].speed = 0; anim.Play(animName); - anim[animName].normalizedTime = 1; - animDot = DOTween.To(() => anim[animName].normalizedTime, v => anim[animName].normalizedTime = v, 0, anim[animName].length / Math.Abs(curSpeed)); - animDot.onComplete = () => - { - anim.Stop(); - }; + this.Finish(); } else { - anim[animName].speed = curSpeed; - anim.Play(animName); - if (anim[animName].wrapMode == WrapMode.Loop) + float curSpeed = 1; + if (string.IsNullOrEmpty(speed) == false) { - this.Finish(); + float.TryParse(speed, out curSpeed); } + + if (curSpeed < 0) + { + anim.Play(animName); + anim[animName].normalizedTime = 1; + animDot = DOTween.To(() => anim[animName].normalizedTime, v => anim[animName].normalizedTime = v, 0, anim[animName].length / Math.Abs(curSpeed)); + animDot.onComplete = () => + { + anim.Stop(); + }; + } + else + { + anim[animName].speed = curSpeed; + anim.Play(animName); + if (anim[animName].wrapMode == WrapMode.Loop) + { + this.Finish(); + } + } + totalTime = Math.Abs(anim[animName].length / curSpeed); } - totalTime = Math.Abs(anim[animName].length / curSpeed); + } + catch (Exception) + { + anim = obj.GetComponent(); + Debug.LogError($"{path} 播放动画 {animName} 出错"); } } - catch (Exception) - { - Debug.LogError($"{path} 播放动画 {animName} 出错"); - } + } else @@ -151,7 +157,10 @@ namespace QFramework { if (obj != null) { - anim?.Stop(); + if (anim!=null) + { + anim.Stop(); + } } animDot?.Kill(); OnFinished = null; diff --git a/Assets/Scripts/Controller/ScoreController.cs b/Assets/Scripts/Controller/ScoreController.cs index 460ded4d..65f7f5c0 100644 --- a/Assets/Scripts/Controller/ScoreController.cs +++ b/Assets/Scripts/Controller/ScoreController.cs @@ -96,9 +96,6 @@ public class ScoreController : MonoSingleton private void OnQuit(OnModuleQuit quit) { - var data = moduleDict[Global.Instance.curModule.ModuleName]; - var scoreDict = data.scoreDict; - scoreDict.Clear(); TypeEventSystem.Global.UnRegister(OnStart); TypeEventSystem.Global.UnRegister(OnQuit); } diff --git a/Assets/Scripts/Item/Point3DItem.cs b/Assets/Scripts/Item/Point3DItem.cs index d8ca8442..8acfd894 100644 --- a/Assets/Scripts/Item/Point3DItem.cs +++ b/Assets/Scripts/Item/Point3DItem.cs @@ -37,7 +37,7 @@ public class Point3DItem : MonoBehaviour } rotSpeed = data.rotateSpeed; gameObject.GetComponent().sortingOrder = data.order; - TypeEventSystem.Global.Register(OnObjDestroy).UnRegisterWhenGameObjectDestroyed(gameObject); + TypeEventSystem.Global.Register(OnObjDestroy); TypeEventSystem.Global.Register(OnStepChanged); } @@ -49,8 +49,16 @@ public class Point3DItem : MonoBehaviour private void OnObjDestroy(OnPoint3DQuestionDestroy destroy) { + if (gameObject != null) + { + GameObject.Destroy(gameObject); + } + } + private void OnDestroy() + { + TypeEventSystem.Global.UnRegister(OnStepChanged); - GameObject.Destroy(gameObject); + TypeEventSystem.Global.UnRegister(OnObjDestroy); } private void OnMouseUpAsButton() diff --git a/Assets/Scripts/UI/UISetting.cs b/Assets/Scripts/UI/UISetting.cs index 1e4199b8..c64c3346 100644 --- a/Assets/Scripts/UI/UISetting.cs +++ b/Assets/Scripts/UI/UISetting.cs @@ -15,9 +15,11 @@ namespace QFramework.Example mData = uiData as UISettingData ?? new UISettingData(); AudioKit.Settings.MusicVolume.RegisterWithInitValue(v => VoiceSlider.value = v).UnRegisterWhenGameObjectDestroyed(this); + AudioKit.Settings.VoiceVolume.RegisterWithInitValue(v => VoiceSlider.value = v).UnRegisterWhenGameObjectDestroyed(this); VoiceSlider.onValueChanged.AddListener(volume => { AudioKit.Settings.MusicVolume.Value = volume; + AudioKit.Settings.VoiceVolume.Value = volume; }); Global.appSetting.MouseMoveSpeed.RegisterWithInitValue(v => MouseSlider.value = v).UnRegisterWhenGameObjectDestroyed(this); @@ -48,6 +50,10 @@ namespace QFramework.Example { AudioKit.Settings.MusicVolume.Value += value; } + if (AudioKit.Settings.VoiceVolume.Value > 0.1f && AudioKit.Settings.VoiceVolume.Value < 1f) + { + AudioKit.Settings.VoiceVolume.Value += value; + } }