private void OnClick(IAtomAnimationTarget target, RectTransform rect, PointerEventData eventData) { if (!_animationEditContext.CanEdit()) { return; } Vector2 localPosition; if (!RectTransformUtility.ScreenPointToLocalPointInRectangle(rect, eventData.position, eventData.pressEventCamera, out localPosition)) { return; } var width = rect.rect.width - _style.KeyframesRowPadding * 2f; var ratio = Mathf.Clamp01((localPosition.x + width / 2f) / width); var clickedTime = ratio * _clip.animationLength; var previousClipTime = _animationEditContext.clipTime; _animationEditContext.clipTime = target.GetTimeClosestTo(clickedTime); if (!_animationEditContext.IsSelected(target)) { _animationEditContext.SetSelected(target, true); if (!Input.GetKey(KeyCode.LeftControl)) { foreach (var t in _animationEditContext.selectedTargets.Where(x => x != target).ToList()) { _animationEditContext.SetSelected(t, false); } } } else if (previousClipTime == _animationEditContext.clipTime) { _animationEditContext.SetSelected(target, false); if (!Input.GetKey(KeyCode.LeftControl)) { foreach (var t in _animationEditContext.selectedTargets.Where(x => x != target).ToList()) { _animationEditContext.SetSelected(t, false); } } } }
private void OnClick(IAtomAnimationTarget target, RectTransform rect, PointerEventData eventData) { if (SuperController.singleton.gameMode != SuperController.GameMode.Edit) { return; } Vector2 localPosition; if (!RectTransformUtility.ScreenPointToLocalPointInRectangle(rect, eventData.position, eventData.pressEventCamera, out localPosition)) { return; } var width = rect.rect.width - _style.KeyframesRowPadding * 2f; var ratio = Mathf.Clamp01((localPosition.x + width / 2f) / width); var clickedTime = ratio * _clip.animationLength; var previousClipTime = _animation.clipTime; _animation.clipTime = target.GetTimeClosestTo(clickedTime); if (!target.selected) { target.selected = true; if (!Input.GetKey(KeyCode.LeftControl)) { foreach (var t in _clip.GetAllTargets().Where(x => x.selected && x != target)) { t.selected = false; } } } else if (previousClipTime == _animation.clipTime) { target.selected = false; if (!Input.GetKey(KeyCode.LeftControl)) { foreach (var t in _clip.GetAllTargets().Where(x => x.selected && x != target)) { t.selected = false; } } } }