AudioAsset
Ease
FastString
FontAsset
NineSlice
PackedSprite
PackedSpriteID
RB
   HardwareSettings
   IRetroBlitGame
RBAsset
Rect2i
ShaderAsset
SoundReference
SpriteGrid
SpriteSheetAsset
TMXMapAsset
   TMXLayer
   TMXLayerLoadState
   TMXObject
   TMXObjectGroup
   TMXProperties
Vector2i

RB.DisplayModeSet

Method  -  Static

public static bool DisplayModeSet(Vector2i resolution, PixelStyle pixelStyle = PixelStyle.Square)

Parameters

resolution Vector2i Resolution, dimensions must be multiple of 2.
pixelStyle PixelStyle Pixel style, one of RB.PixelStyle.Square, RB.PixelStyle.Wide, RB.PixelStyle.Tall

Returns

bool

True if mode was successfully set, false otherwise.

Description

Sets display mode to given resolution and pixel style. Note that this sets only the RetroBlit pixel resolution, and does not affect the native window size. To change the native window size you can use the Unity Screen.SetResolution method.

Note that the initial display resolution is always set in RB.IRetroBlitGame.QueryHardware.

This method cannot be called from within RB.IRetroBlitGame.Render method.

Example

// Track previous native screen size
Vector2i previousNativeRes;

void Update() {
    // Get the current screen resolution from Unity
    var currentNativeRes = new Vector2i(Screen.width, Screen.height);

    // If the current size is different than previous size then update RetroBlit resolution.
    // This keeps the RetroBlit resolution at half the native resolution, essentially keeping
    // the pixel size at 2x2 native pixel size.
    if (currentNativeRes != previousNativeRes) {
        RB.DisplayModeSet(new Vector2i(Screen.width / 2, Screen.height / 2));
    }

    previousNativeRes = new Vector2i(Screen.width, Screen.height);
}

See Also

RB.DisplaySize
RB.PixelStyle
RB.IRetroBlitGame.QueryHardware