2D Toolkit Forum
2D Toolkit => Support => Topic started by: PDZ on November 05, 2013, 03:42:31 pm
-
Hey,
I am using the Override function 'Fit Width', which means when I run at a higher resolution there are strips along the top and the bottom of the screen. How might I position my camera programmatically so that there is no strip along the bottom and it is all at the top of the screen?
The difference in y resolution between my native (640) and the target resolution I am testing against (768) is 128. However seeing it in the editor I need to move my camera 40 pixels up on the Y to hide the bottom strip. What is the math I need to be using? Finding the difference between the target and the native resolutions doesn't seem to be the solution.
Thanks in advance.
-
In tk2dCamera.cs, these lines reposition the camera after scaling:
if (currentResolutionOverride.autoScaleMode != tk2dCameraResolutionOverride.AutoScaleMode.StretchToFit)
{
switch (currentResolutionOverride.fitMode)
{
case tk2dCameraResolutionOverride.FitMode.Center:
offset = new Vector2(Mathf.Round((settings.nativeResolutionWidth * scale.x - pixelWidth ) / 2.0f),
Mathf.Round((settings.nativeResolutionHeight * scale.y - pixelHeight) / 2.0f));
break;
default:
case tk2dCameraResolutionOverride.FitMode.Constant:
offset = -currentResolutionOverride.offsetPixels; break;
}
}
You can disable the re-entering vertically if you like, or simply add another fit mode to do this for you.
-
In tk2dCamera.cs, these lines reposition the camera after scaling:
if (currentResolutionOverride.autoScaleMode != tk2dCameraResolutionOverride.AutoScaleMode.StretchToFit)
{
switch (currentResolutionOverride.fitMode)
{
case tk2dCameraResolutionOverride.FitMode.Center:
offset = new Vector2(Mathf.Round((settings.nativeResolutionWidth * scale.x - pixelWidth ) / 2.0f),
Mathf.Round((settings.nativeResolutionHeight * scale.y - pixelHeight) / 2.0f));
break;
default:
case tk2dCameraResolutionOverride.FitMode.Constant:
offset = -currentResolutionOverride.offsetPixels; break;
}
}
You can disable the re-entering vertically if you like, or simply add another fit mode to do this for you.
Cool, thanks for the reply!