SetScaleFocused() public method

public SetScaleFocused ( Vector2 focalPoint, Vector2 newScale ) : void
focalPoint Vector2
newScale Vector2
return void
コード例 #1
0
        void SnapZoom(float newZoom)
        {
            var logScale = Mathf.Log10(newZoom);
            var logMin   = Mathf.Log10(minScale);
            var logMax   = Mathf.Log10(maxScale);
            var shortestSliderDistance = System.Single.MaxValue;

            if (logScale > logMin && logScale < logMax)
            {
                for (var i = 1; i <= maxScale; ++i)
                {
                    // Snap distance is defined in points, so convert difference back to UI space
                    var sliderDistanceToI = kScaleSliderMaxWidth * Mathf.Abs(logScale - Mathf.Log10(i)) / (logMax - logMin);
                    if (sliderDistanceToI < kScaleSliderSnapThreshold && sliderDistanceToI < shortestSliderDistance)
                    {
                        newZoom = i;
                        shortestSliderDistance = sliderDistanceToI;
                    }
                }
            }

            var areaInMargins = m_ZoomArea.shownAreaInsideMargins;
            var focalPoint    = areaInMargins.position + areaInMargins.size * 0.5f;

            m_ZoomArea.SetScaleFocused(focalPoint, Vector2.one * newZoom);
        }