public bool TargetsSameAs(IAnimationTargetWithCurves target) { var t = target as FloatParamAnimationTarget; if (t == null) { return(false); } return(t.storable == storable && t.floatParam == floatParam); }
public bool TargetsSameAs(IAnimationTargetWithCurves target) { var t = target as FreeControllerAnimationTarget; if (t == null) { return(false); } return(t.controller == controller); }
private void BindCurves(IAnimationTargetWithCurves target) { var lead = target.GetLeadCurve(); if (lead.length < 2) { return; } _animationLength = lead[lead.length - 1].time; if (target is FreeControllerAnimationTarget) { var targetController = (FreeControllerAnimationTarget)target; // To display rotation, we have to build custom curves. But it's not that useful. // var rotVX = new Keyframe[targetController.RotX.length]; // var rotVY = new Keyframe[targetController.RotY.length]; // var rotVZ = new Keyframe[targetController.RotZ.length]; // for (var t = 0; t < targetController.RotW.length; t++) // { // Keyframe keyX = targetController.RotX[t]; // Keyframe keyY = targetController.RotY[t]; // Keyframe keyZ = targetController.RotZ[t]; // Keyframe keyW = targetController.RotW[t]; // var rot = new Quaternion( // keyX.value, // keyY.value, // keyZ.value, // keyW.value // ); // var eulerAngles = rot.eulerAngles; // rotVX[t] = new Keyframe(keyW.time, eulerAngles.x); // rotVY[t] = new Keyframe(keyW.time, eulerAngles.y); // rotVZ[t] = new Keyframe(keyW.time, eulerAngles.z); // } // _lines.AddCurve(new Color(1.0f, 0.8f, 0.8f), new AnimationCurve(rotVX)); // _lines.AddCurve(new Color(0.8f, 1.0f, 0.8f), new AnimationCurve(rotVY)); // _lines.AddCurve(new Color(0.8f, 0.8f, 1.0f), new AnimationCurve(rotVZ)); var range = EstimateRange(targetController.x, targetController.y, targetController.z); _lines.range = new Vector2(Mathf.Min(_lines.range.x, range.x), Mathf.Max(_lines.range.y, range.y)); _lines.AddCurve(_style.CurveLineColorX, targetController.x); _lines.AddCurve(_style.CurveLineColorY, targetController.y); _lines.AddCurve(_style.CurveLineColorZ, targetController.z); } else if (target is FloatParamAnimationTarget) { var targetParam = (FloatParamAnimationTarget)target; var range = EstimateRange(targetParam.value); _lines.range = new Vector2(Mathf.Min(_lines.range.x, range.x), Mathf.Max(_lines.range.y, range.y)); _lines.AddCurve(_style.CurveLineColorFloat, targetParam.value); } }
private void OnClick(IAnimationTargetWithCurves target, RectTransform rect, PointerEventData eventData) { if (_locked) { return; } Vector2 localPosition; if (!RectTransformUtility.ScreenPointToLocalPointInRectangle(rect, eventData.position, eventData.pressEventCamera, out localPosition)) { return; } var curve = target.GetLeadCurve(); var width = rect.rect.width - _style.KeyframesRowPadding * 2f; var ratio = Mathf.Clamp01((localPosition.x + width / 2f) / width); var closest = curve.KeyframeBinarySearch(ratio * _clip.animationLength, true); var time = curve[closest].time; _animation.Time = time; }