docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class GameViewSize

    Utility class to manage the Game View size

    Inheritance
    object
    GameViewSize
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: UnityEditor.TestTools.Graphics
    Assembly: UnityEditor.TestTools.Graphics.dll
    Syntax
    [InitializeOnLoad]
    public static class GameViewSize
    Remarks

    This class is used to set the Game View size to a custom size, get the current Game View size, add a custom size to the list of available sizes, and select a Game View size. It also provides methods to backup and restore the Game View size.

    Properties

    CurrentSize

    Current size of the Game View

    Declaration
    public static object CurrentSize { get; }
    Property Value
    Type Description
    object

    The current size of the Game View

    Remarks

    This property retrieves the current size of the Game View by accessing the currentGameViewSize property of the Game View class. The size is returned as an object that contains the width and height values.

    currentSize

    Current size of the Game View

    Declaration
    [Obsolete("currentSize is deprecated. Use CurrentSize instead. (UnityUpgradable) -> CurrentSize", true)]
    public static object currentSize { get; }
    Property Value
    Type Description
    object

    The current size of the Game View

    Remarks

    This property retrieves the current size of the Game View by accessing the currentGameViewSize property of the Game View class. The size is returned as an object that contains the width and height values.

    Methods

    AddSize(int, int)

    Add a custom game view size to the list of available sizes

    Declaration
    public static object AddSize(int width, int height)
    Parameters
    Type Name Description
    int width

    The width of the Game View

    int height

    The height of the Game View

    Returns
    Type Description
    object

    The new size object

    Remarks

    This method creates a new Game View size object and adds it to the list of available sizes in the Game View. The new size object is created with the specified width and height values.

    BackupCurrentSize()

    Backup the current size of the Game View

    Declaration
    public static void BackupCurrentSize()
    Remarks

    This method backs up the current size of the Game View by storing it in a static variable. This allows the size to be restored later using RestoreSize()

    GetGameRenderSize(out int, out int)

    Get the Game View size

    Declaration
    public static void GetGameRenderSize(out int width, out int height)
    Parameters
    Type Name Description
    int width

    The width of the Game View

    int height

    The height of the Game View

    Remarks

    This method retrieves the size of the Game View by accessing the targetSize property of the Game View class.

    RestoreSize()

    Restore the Game View to its initial size

    Declaration
    public static void RestoreSize()
    Remarks

    This method restores the Game View to its initial size by selecting the size object stored earlier by BackupCurrentSize(). This allows the Game View to return to its original size after a custom size has been set.

    SelectSize(object)

    Select a Game View size

    Declaration
    public static void SelectSize(object size)
    Parameters
    Type Name Description
    object size

    The size to select

    Remarks

    This method selects a Game View size by invoking the SizeSelectionCallback method of the Game View class. The size parameter is the size object to select.

    SetCustomSize(int, int)

    Create and set a custom size for the Game View

    Declaration
    public static object SetCustomSize(int width, int height)
    Parameters
    Type Name Description
    int width

    The width of the Game View

    int height

    The height of the Game View

    Returns
    Type Description
    object

    The new size object

    Remarks

    This method creates a new Game View size object and sets its width and height properties to the specified values. It then adds the new size object to the list of available sizes in the Game View.

    SetGameViewSize(int, int)

    Sets the Game View size to a custom size

    Declaration
    public static void SetGameViewSize(int width, int height)
    Parameters
    Type Name Description
    int width

    The width to set the Game View to

    int height

    The height to set the Game View to

    In This Article
    Back to top
    Copyright © 2026 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)