private void ChangeCurve(string val) { if (!_animationEditContext.CanEdit()) { RefreshCurrentCurveType(_animationEditContext.clipTime); return; } if (string.IsNullOrEmpty(val) || val.StartsWith("(")) { RefreshCurrentCurveType(_animationEditContext.clipTime); return; } var time = _animationEditContext.clipTime.Snap(); var curveType = CurveTypeValues.ToInt(val); foreach (var target in _animationEditContext.GetAllOrSelectedTargets().OfType <ICurveAnimationTarget>()) { target.ChangeCurve(time, curveType); } if (curveType == CurveTypeValues.CopyPrevious) { _animationEditContext.Sample(); } RefreshCurrentCurveType(_animationEditContext.clipTime); }
private void HandleControllerChanged(FreeControllerV3 controller, bool grabEnd) { // Only record moves in edit mode if (!animationEditContext.CanEdit()) { return; } // Ignore grabbed event, we will receive the grab end later if (controller.isGrabbing || controller.possessed) { return; } // Do not create a keyframe when loading a preset if (controller.isPresetRestore) { return; } // Ignore comply nodes unless the event is grab end, since they will dispatch during the animation if (!grabEnd && (controller.currentRotationState == FreeControllerV3.RotationState.Comply || controller.currentPositionState == FreeControllerV3.PositionState.Comply)) { return; } // Only track animated targets var target = animationEditContext.current.targetControllers.FirstOrDefault(t => t.controller == controller); if (target == null) { return; } // Ignore grab release at the end of a mocap recording if (animationEditContext.ignoreGrabEnd) { return; } RecordFreeControllerPosition(target); }
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); } } } }