public static void RestoreGameViewSize() { // Restore previous size id GameViewUtils.SetCurrentSizeIndex(m_PreviousSizeId); #if (UNITY_5_4_OR_NEWER) // Restore previous gameview size // GameViewUtils.SetGameViewSize((int)m_PreviousWidth, (int)m_PreviousHeight); // Remove temp size id //int size = GameViewUtils.FindSize(m_AspectName); //if (size != -1) { // GameViewUtils.RemoveCustomSize(size); //} #else // Restore gameview rect GameViewUtils.GetGameView().minSize = m_PreviousMinSize; GameViewUtils.GetGameView().maxSize = m_PreviousMaxSize; GameViewUtils.SetGameViewRect(m_PreviousRect); #endif // Restore previous focus windows if (m_PreviousWindowFocus != null) { m_PreviousWindowFocus.Focus(); } }
public static void SetGameViewSize(int width, int height) { #if (UNITY_5_4_OR_NEWER) // Checks if temp size exists, creates it if needed if (!GameViewUtils.SizeExists(m_AspectName)) { GameViewUtils.AddCustomSize(GameViewUtils.SizeType.FIXED_RESOLUTION, width, height, m_AspectName); } // Set the size of the custom size int size = GameViewUtils.FindSize(m_AspectName); if (size == -1) { Debug.LogError("Can not find the gameview size " + m_AspectName); return; } GameViewUtils.SetCurrentSizeIndex(size); // Change the size GameViewUtils.SetGameViewSize(width, height); #else // Force Free aspect GameViewUtils.SetSize(0); // Change rect size int topOffset = 17; GameViewUtils.GetGameView().minSize = new Vector2(width, height + topOffset); GameViewUtils.GetGameView().maxSize = new Vector2(width, height + topOffset); GameViewUtils.SetGameViewRect(new Rect(m_PreviousRect.x, m_PreviousRect.y, width, height + topOffset)); // Force repaint for "waitendoframe" GameViewUtils.GetGameView().Repaint(); #endif }