protected IEnumerator InteractionLoop(ControllerInteractionPoint interactionPoint, CoroutineHandle handle)
        {
            var sizeMagnitude = GetMagnitude(barRegion.rect.size);
            var pivot         = GetMagnitude(barRegion.pivot);

            float PointToMagnitude(Vector3 pos)
            {
                var magnitude = (sizeMagnitude * pivot) + GetMagnitude(pos);

                // Scale to 0-1 values, with unclamped values <0,>1
                return(magnitude / sizeMagnitude);
            }

            var lastAbsScale = PointToMagnitude(barRegion.InverseTransformPoint(interactionPoint.transform.position));

            yield return(null);

            var lastSensorZoom = sensorZoom;

            while (handle.Running)
            {
                var absScale = PointToMagnitude(barRegion.InverseTransformPoint(interactionPoint.transform.position));

                var delta = absScale - lastAbsScale;


                // Clamp sensor zoom scale to the -/+1 range
                sensorZoom = Mathf.Clamp(sensorZoom + delta * 2, -1, 1);

                // Set vJoy axis
                output.SetSensorZoom(sensorZoom);

                // Move the bar and re-render the overlay on-demand when the bar has been moved a notable distance
                var updateScale     = 0.01f;
                var sensorZoomDelta = sensorZoom - lastSensorZoom;
                if (Math.Abs(sensorZoomDelta) > updateScale)
                {
                    var roundedSensorZoom = Mathf.Round(sensorZoom / updateScale) * updateScale;
                    var barMag            = ((roundedSensorZoom / 2f + 0.5f) - pivot) * sizeMagnitude;
                    barMid.anchoredPosition = SetMagnitude2(barMid.anchoredPosition, barMag);

                    lastSensorZoom = sensorZoom;
                    OnDemandRenderer.SafeDirty(gameObject);
                }

                lastAbsScale = absScale;
                yield return(null);
            }
        }
 private void Refresh(bool isFacingHmd)
 {
     image.sprite    = isFacingHmd ? sprite : backface;
     lastIsFacingHmd = isFacingHmd;
     OnDemandRenderer.SafeDirty(gameObject);
 }
 private void OnDisable()
 {
     OnDemandRenderer.Dirty(gameObject);
 }
 public void SetColor(Color color)
 {
     image.color = color;
     OnDemandRenderer.SafeDirty(gameObject);
 }