// Update is called once per frame void Update() { if (Screen.width != screenSize.x || Screen.height != screenSize.y) { screenSize = new Vector2Int(Screen.width, Screen.height); ScreenSizeChanged?.Invoke(screenSize); } }
void Update() { if (Screen.width != prevScreenWidth || Screen.height != prevScreenHeight) { if (ScreenSizeChanged != null) { ScreenSizeChanged.Invoke(); } prevScreenWidth = Screen.width; prevScreenHeight = Screen.height; } }
void resized(OSWindow window) { if (ScreenSizeChanging != null) { ScreenSizeChanging.Invoke(window.WindowWidth, window.WindowHeight); } layoutChain.WorkingSize = new IntSize2(window.WindowWidth, window.WindowHeight); layoutChain.layout(); if (ScreenSizeChanged != null) { ScreenSizeChanged.Invoke(window.WindowWidth, window.WindowHeight); } }
public static void SetSize(int width, int height) { var oldWidth = Width; var oldHeight = Height; Width = width < 0 ? throw new ArgumentOutOfRangeException(nameof(width)) : width; Height = height < 0 ? throw new ArgumentOutOfRangeException(nameof(height)) : height; if (width != oldWidth || height != oldHeight) { factor = new Vector2(1.0f / width, 1.0f / height); ScreenSizeChanged?.Invoke(null, EventArgs.Empty); } }
/// <summary> /// Setup the helper. /// </summary> /// <param name="width">The width of the screen.</param> /// <param name="height">The height of the screen.</param> /// <param name="lockCursor">Indicates whether the cursor is locked.</param> /// <param name="showCursor">Indicates whether the cursor is visible.</param> public static void Setup(int width, int height, bool?lockCursor, bool?showCursor) { ScreenRect = new Rectangle(0, 0, width, height); WidthPerTwo = width >> 1; HeightPerTwo = height >> 1; if (lockCursor.HasValue) { LockCursor = lockCursor.Value; } if (showCursor.HasValue) { ShowCursor = showCursor.Value; } ScreenSizeChanged?.Invoke(width, height); }
internal Task UpdateDisplayInformation(int newScreenHeight, int newScreenWidth) { lock (_lockObject) { var newHeight = newScreenHeight; var newWidth = newScreenWidth; var resolutionChanged = newHeight != _cachedScreenHeight || newWidth != _cachedScreenWidth; _cachedScreenHeight = newHeight; _cachedScreenWidth = newWidth; if (resolutionChanged) { // Don't want to invoke this on the UI thread, so wrap in a task to be safe. return(Task.Run(() => { ScreenSizeChanged?.Invoke(null, EventArgs.Empty); })); } return(Task.CompletedTask); } }
protected virtual void OnScreenSizeChange(float width, float height) { ScreenSizeChanged?.Invoke(width, height); }