protected virtual void HandleScaleWithScreenSize()
{
Vector2 vector = new Vector2((float) Screen.width, (float) Screen.height);
int targetDisplay = this.m_Canvas.targetDisplay;
if ((targetDisplay > 0) && (targetDisplay < Display.displays.Length))
{
Display display = Display.displays[targetDisplay];
vector = new Vector2((float) display.renderingWidth, (float) display.renderingHeight);
}
float scaleFactor = 0f;
switch (this.m_ScreenMatchMode)
{
case ScreenMatchMode.MatchWidthOrHeight:
{
float a = Mathf.Log(vector.x / this.m_ReferenceResolution.x, 2f);
float b = Mathf.Log(vector.y / this.m_ReferenceResolution.y, 2f);
float p = Mathf.Lerp(a, b, this.m_MatchWidthOrHeight);
scaleFactor = Mathf.Pow(2f, p);
break;
}
case ScreenMatchMode.Expand:
scaleFactor = Mathf.Min((float) (vector.x / this.m_ReferenceResolution.x), (float) (vector.y / this.m_ReferenceResolution.y));
break;
case ScreenMatchMode.Shrink:
scaleFactor = Mathf.Max((float) (vector.x / this.m_ReferenceResolution.x), (float) (vector.y / this.m_ReferenceResolution.y));
break;
}
this.SetScaleFactor(scaleFactor);
this.SetReferencePixelsPerUnit(this.m_ReferencePixelsPerUnit);
}