Exemplo n.º 1
0
 private void Update()
 {
     if (this.shouldExit)
     {
         this.DoExitGame();
     }
     else if (this.bridge != null)
     {
         if ((this.oldWidth != ((int)base.position.width)) || (this.oldHeight != ((int)base.position.height)))
         {
             int  num            = (int)Mathf.Clamp(base.position.width, base.minSize.x, 1280f);
             int  num2           = (int)Mathf.Clamp(base.position.height, base.minSize.y, 720f);
             bool fitsInsideRect = true;
             this.remoteViewRect         = GameViewSizes.GetConstrainedRect(new Rect(0f, 0f, (float)num, (float)num2), ScriptableSingleton <GameViewSizes> .instance.currentGroupType, ScriptableSingleton <NScreenManager> .instance.SelectedSizeIndex, out fitsInsideRect);
             this.remoteViewRect.y      += this.ToolBarHeight;
             this.remoteViewRect.height -= this.ToolBarHeight;
             this.bridge.SetResolution((int)this.remoteViewRect.width, (int)this.remoteViewRect.height);
             this.oldWidth  = (int)base.position.width;
             this.oldHeight = (int)base.position.height;
         }
         this.bridge.Update();
         base.Repaint();
     }
     if (this.shouldBuild)
     {
         this.shouldBuild = false;
         NScreenManager.Build();
     }
 }
Exemplo n.º 2
0
        public static void ClearResolution()
        {
            if (CustomResolution != null)
            {
                EditorWindow gameView = GetGameView();
                bool         customResolutionActive = gameView && CustomResolutionIndex == (int)gameView.FetchProperty("selectedSizeIndex");

                GameViewSizes.CallMethod("RemoveCustomSize", CustomResolutionIndex);
                CustomResolution = null;

                if (customResolutionActive)
                {
                    gameView.CallMethod("SizeSelectionCallback", Mathf.Clamp(PlayerPrefs.GetInt(PREVIOUS_RESOLUTION_PREF), 0, (int)GameViewSizes.CallMethod("GetTotalCount") - 1), null);

                    ZoomOutGameView();
                    RefreshMockups();
                }
            }
        }
Exemplo n.º 3
0
        public static void SetResolution(int width, int height, bool aspectRatioMode)
        {
            EditorWindow gameView = GetGameView();

            if (!gameView)
            {
#if UNITY_2019_3_OR_NEWER
                // On 2019.3 and later, we can resize canvases even when there is no open Game window. On earlier versions, unfortunately it is not possible
                if (!NotchSolutionUtilityEditor.UnityDeviceSimulatorActive)
                {
                    SceneView sceneView = SceneView.lastActiveSceneView ?? SceneView.currentDrawingSceneView;
                    if (sceneView)
                    {
                        sceneView.CallMethod("SetMainPlayModeViewSize", new Vector2(width, height));
                        RefreshMockups();
                    }
                }
#endif

                return;
            }

            object customResolution = CustomResolution;
            if (customResolution != null)
            {
                bool isModified = false;

                if ((customResolution.FetchProperty("sizeType").Equals(AspectRatioMode)) != aspectRatioMode)
                {
                    customResolution.ModifyProperty("sizeType", aspectRatioMode ? AspectRatioMode : FixedResolutionMode);
                    isModified = true;
                }

                if ((int)customResolution.FetchProperty("width") != width)
                {
                    customResolution.ModifyProperty("width", width);
                    isModified = true;
                }

                if ((int)customResolution.FetchProperty("height") != height)
                {
                    customResolution.ModifyProperty("height", height);
                    isModified = true;
                }

                if (!isModified)
                {
                    return;
                }
                else if (CustomResolutionIndex == (int)gameView.FetchProperty("selectedSizeIndex"))
                {
                    ZoomOutGameView();
                    RefreshMockups();

                    return;
                }
            }
            else
            {
                CustomResolution = customResolution = GetType("GameViewSize").CreateInstance(aspectRatioMode ? AspectRatioMode : FixedResolutionMode, width, height, TEMPORARY_RESOLUTION_LABEL);
                GameViewSizes.CallMethod("AddCustomSize", customResolution);
            }

            PlayerPrefs.SetInt(PREVIOUS_RESOLUTION_PREF, (int)gameView.FetchProperty("selectedSizeIndex"));
            gameView.CallMethod("SizeSelectionCallback", CustomResolutionIndex, null);

            ZoomOutGameView();
            RefreshMockups();
        }