// Utility public void StartAimCoroutine(MonoBehaviour owner, bool isEnteringAimMode) { // Choose zoom in or out float targetZoom = 0f; Func <bool> test = () => _zoomControlAmount.Value < targetZoom + AIM_COROUTINE_MARGIN; if (isEnteringAimMode) { targetZoom = 1f; test = () => _zoomControlAmount.Value > targetZoom - AIM_COROUTINE_MARGIN; } // Update over time if (_aimCoroutine != null) { owner.StopCoroutine(_aimCoroutine); } _aimCoroutine = owner.ExecuteUntil ( test, () => _zoomControlAmount.Value = _zoomControlAmount.Value.Lerp(targetZoom, AIM_COROUTINE_UPDATE_SPEED), () => _zoomControlAmount.Value = targetZoom ); }