private void OnFogLightDrag(GameObject go, PointerEventData eventData) { Vector2 passPos = eventData.pressPosition; Vector2 currPos = eventData.position; if (Vector2.Distance(passPos, currPos) > 10f && (Mathf.Abs(passPos.x - currPos.x) < Mathf.Abs(passPos.y - currPos.y))) //滑动小了不触发 { if (currPos.y > passPos.y && fogSwitchState != FogSwitchState.Open) //右上 { fogSwitchState = FogSwitchState.Open; controlRodNormal.imgFogLight.sprite = controlRodNormal.sprFogLightOpen; //controlRodBackward1.imgFogLight.sprite = controlRodBackward1.sprFogLightOpen; //controlRodBackward2.imgFogLight.sprite = controlRodBackward1.sprFogLightOpen; if (!FrontFogSwitch) { FrontFogSwitch = true; AudioSystemMgr.Instance.PlaySoundByClip(ResourcesMgr.Instance.LoadAudioClip("L Effect01")); } else if (!RearFogSwitch) { RearFogSwitch = true; AudioSystemMgr.Instance.PlaySoundByClip(ResourcesMgr.Instance.LoadAudioClip("L Effect01")); } } else if (currPos.y < passPos.y && fogSwitchState != FogSwitchState.Close) { fogSwitchState = FogSwitchState.Close; controlRodNormal.imgFogLight.sprite = controlRodNormal.sprFogLightClose; if (RearFogLamp) { RearFogSwitch = false; AudioSystemMgr.Instance.PlaySoundByClip(ResourcesMgr.Instance.LoadAudioClip("L Effect01")); } else if (FrontFogSwitch) { FrontFogSwitch = false; AudioSystemMgr.Instance.PlaySoundByClip(ResourcesMgr.Instance.LoadAudioClip("L Effect01")); } } } else if (fogSwitchState != FogSwitchState.Normal) { fogSwitchState = FogSwitchState.Normal; controlRodNormal.imgFogLight.sprite = controlRodNormal.sprFogLoghtNormal; } //OnSwitchChange(); }
private void OnFogLightDragEnd(GameObject go, PointerEventData eventData) { fogSwitchState = FogSwitchState.Normal; controlRodNormal.imgFogLight.sprite = controlRodNormal.sprFogLoghtNormal; OnSwitchChange(); }
private void OnFogLightDragBegin(GameObject go, PointerEventData eventData) { fogSwitchState = FogSwitchState.Normal; }