internal static void RespawnMockup() { //When the game view is changed, the mockup sometimes disappears or isn't scaled correctly if (gameviewResolution != NotchSimulatorUtility.GetMainGameViewSize()) { DestroyHiddenCanvas(); //So we delete the old canvas UpdateAllMockups(); //And we respawn it UpdateSimulatorTargets(); gameviewResolution = NotchSimulatorUtility.GetMainGameViewSize(); //Update the saved game view } }
/// <summary> /// It is currently active only when Notch Simulator tab is present. /// </summary> void OnGUI() { win = this; //Sometimes even with flag I can see it in hierarchy until I move a mouse over it?? EditorApplication.RepaintHierarchyWindow(); EditorGUI.BeginChangeCheck(); var settings = Settings.Instance; string switchConfigShortcut = ShortcutManager.instance.GetShortcutBinding(NotchSolutionShortcuts.switchConfigurationShortcut).ToString(); if (string.IsNullOrEmpty(switchConfigShortcut)) { switchConfigShortcut = "None"; } string simulateShortcut = ShortcutManager.instance.GetShortcutBinding(NotchSolutionShortcuts.toggleSimulationShortcut).ToString(); if (string.IsNullOrEmpty(simulateShortcut)) { simulateShortcut = "None"; } settings.EnableSimulation = EditorGUILayout.BeginToggleGroup($"Simulate ({simulateShortcut})", settings.EnableSimulation); int previousIndex = settings.ActiveConfiguration.DeviceIndex; int currentIndex = Mathf.Clamp(settings.ActiveConfiguration.DeviceIndex, 0, SimulationDatabase.KeyList.Length - 1); int selectedIndex = EditorGUILayout.Popup(currentIndex, SimulationDatabase.KeyList); if (GUILayout.Button($"{settings.ActiveConfiguration.ConfigurationName} ({switchConfigShortcut})", EditorStyles.helpBox)) { NotchSolutionShortcuts.SwitchConfiguration(); } EditorGUILayout.EndToggleGroup(); settings.ActiveConfiguration.DeviceIndex = selectedIndex; var simulationDevice = SimulationDatabase.Get(SimulationDatabase.KeyList[selectedIndex]); //Draw warning about wrong aspect ratio if (settings.EnableSimulation && simulationDevice != null) { ScreenOrientation gameViewOrientation = NotchSimulatorUtility.GetGameViewOrientation(); Vector2 gameViewSize = NotchSimulatorUtility.GetMainGameViewSize(); if (gameViewOrientation == ScreenOrientation.Landscape) { var flip = gameViewSize.x; gameViewSize.x = gameViewSize.y; gameViewSize.y = flip; } var screen = simulationDevice.Screens.FirstOrDefault(); var simAspect = NotchSolutionUtilityEditor.ScreenRatio(new Vector2(screen.width, screen.height)); var gameViewAspect = NotchSolutionUtilityEditor.ScreenRatio(gameViewSize); var aspectDiff = Math.Abs((simAspect.x / simAspect.y) - (gameViewAspect.x / gameViewAspect.y)); if (aspectDiff > 0.01f) { EditorGUILayout.HelpBox($"The selected simulation device has an aspect ratio of {simAspect.y}:{simAspect.x} ({screen.height}x{screen.width}) but your game view is currently in aspect {gameViewAspect.y}:{gameViewAspect.x} ({gameViewSize.y}x{gameViewSize.x}). The overlay mockup won't be displayed correctly.", MessageType.Warning); } } bool changed = EditorGUI.EndChangeCheck(); if (changed) { UpdateAllMockups(); settings.Save(); } UpdateSimulatorTargets(); }