예제 #1
0
 // 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;
     }
 }
예제 #3
0
 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);
     }
 }
예제 #4
0
파일: UiCanvas.cs 프로젝트: Babelz/Fracture
        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);
            }
        }
예제 #5
0
파일: Screen.cs 프로젝트: redchew-fork/C3DE
        /// <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);
        }
예제 #6
0
 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);
     }
 }
예제 #7
0
 protected virtual void OnScreenSizeChange(float width, float height)
 {
     ScreenSizeChanged?.Invoke(width, height);
 }