public virtual void BeginRecording() { Screen.orientation = ScreenOrientation.Landscape; int w, h; GameViewSize.GetGameRenderSize(out w, out h); switch (recorder.defaultResolution) { case Resolution.Window: { outputWidth = (w + 1) & ~1; outputHeight = (h + 1) & ~1; break; } default: { outputHeight = (int)recorder.defaultResolution; outputWidth = (int)(outputHeight * AspectRatioHelper.GetRealAR(recorder.defaultAspectRatio)); outputWidth = (outputWidth + 1) & ~1; outputHeight = (outputHeight + 1) & ~1; break; } } //Debug.Log("Screen resolution: " + w + "x" + h); if (w != outputWidth || h != outputHeight) { Debug.Log("[VimeoRecorder] Setting window size to: " + outputWidth + "x" + outputHeight); var size = GameViewSize.SetCustomSize(outputWidth, outputHeight) ?? GameViewSize.AddSize(outputWidth, outputHeight); if (GameViewSize.m_ModifiedResolutionCount == 0) { GameViewSize.BackupCurrentSize(); } else { if (size != GameViewSize.currentSize) { Debug.LogError("[VimeoRecorder] Requestion a resultion change while a recorder's input has already requested one! Undefined behaviour."); } } GameViewSize.m_ModifiedResolutionCount++; m_ModifiedResolution = true; GameViewSize.SelectSize(size); } }
/// <summary> /// Used to Start the recording with current settings. /// If not already the case, the Editor will also switch to PlayMode. /// </summary> public void StartRecording() { if (EditorApplication.isPlaying) { // Already in play mode, so start recording now StartRecordingInternal(); } else if (m_State == State.Idle) { // Not playing yet and idle m_State = State.WaitingForPlayModeToStartRecording; GameViewSize.DisableMaxOnPlay(); EditorApplication.isPlaying = true; m_FrameCount = Time.frameCount; } }
public int GetHeight() { if (imageHeight == ImageHeight.Custom) { return(m_CustomHeight); } if (imageHeight == ImageHeight.Window) { int w, h; GameViewSize.GetGameRenderSize(out w, out h); return(h); } return((int)imageHeight); }
bool AllowedToShow(GameViewSize size) { // special treatment for free aspect if (size.width == 0 && size.height == 0) { return(displayFree); } bool allow = (size.width >= size.height && displayLandscape) || (size.width < size.height && displayPortrait); allow = allow && ((size.isCustom && displayCustom) || (!(size.isCustom) && displayBuiltin)); return(allow); }
public int GetWidth() { if (imageHeight == ImageHeight.Custom) { return(m_CustomWidth); } if (imageHeight == ImageHeight.Window) { int w, h; GameViewSize.GetGameRenderSize(out w, out h); return(w); } var aspect = m_AspectRatio.GetAspect(); return((int)(aspect * (int)imageHeight)); }
private void AddSizeToUnity(string name, int width, int height) { RefreshSizes(); try { GameViewSize size = new GameViewSize() { baseText = name, displayText = name, width = width, height = height, index = sizes.Count, isCustom = true, isAspectRatio = false, }; Assembly ass = typeof(EditorApplication).Assembly; Type gameViewSizesType = ass.GetType("UnityEditor.GameViewSizes"); PropertyInfo gameViewSizesInfo = gameViewSizesType.GetMember("instance")[0] as PropertyInfo; object gameViewSizes = gameViewSizesInfo.GetValue(null, new object[] { }); PropertyInfo gameViewSizeGroupInfo = gameViewSizesType.GetMember("currentGroup")[0] as PropertyInfo; object gameViewSizeGroup = gameViewSizeGroupInfo.GetValue(gameViewSizes, new object[] { }); MethodInfo addSizeMethod = gameViewSizeGroup.GetType().GetMethod("AddCustomSize"); addSizeMethod.Invoke(gameViewSizeGroup, new object[] { size.ToInternalObject() }); MethodInfo saveToHddMethod = gameViewSizesType.GetMethod("SaveToHDD"); saveToHddMethod.Invoke(gameViewSizes, new object[] { }); RefreshSizes(); } catch (Exception ex) { Debug.LogErrorFormat("Couldn't create resolution: {0}", ex); } }
void OnGUI() { if (gameSizeType == null) { RefreshSizes(); } Begin(mainSection: false); // Resolutions Begin(mainSection: true); DrawToolStrip(); // settings EditorGUILayout.Separator(); var style = (useBigButtons) ? GUI.skin.button : EditorStyles.toolbarButton; var prevAlign = style.alignment; style.alignment = TextAnchor.MiddleLeft; style.fontSize = 10; int currentIndex = (int)selectedIndex.GetValue(gameView, null); for (int i = 0; i < sizes.Count; i++) { if ((displayFree && i == 1) || (displayBuiltin && i == builtinCount)) { EditorGUILayout.Separator(); } var size = sizes[i]; if (!(AllowedToShow(size))) { continue; } bool isOptimizedRes = (ResolutionMonitor.IsOptimizedResolution(size.width, size.height)); bool isSelected = currentIndex == size.index; style.fontStyle = (isOptimizedRes) ? ((isSelected) ? FontStyle.BoldAndItalic : FontStyle.Italic) : ((isSelected) ? FontStyle.Bold : FontStyle.Normal); if (GUILayout.Button(GetText(size), style)) { SetResolution(size); } } GUILayout.FlexibleSpace(); style.fontStyle = FontStyle.Normal; End(mainSection: true); // Screen Configs if (this.displayScreenConfigs) { Begin(mainSection: true); Action <ScreenTypeConditions, int, int> applyScreenConfig = (config, width, height) => { if (config != null && ResolutionMonitor.SimulatedScreenConfig == config) { ResolutionMonitor.SimulatedScreenConfig = null; } else { ResolutionMonitor.SimulatedScreenConfig = config; if (this.applyScreenConfigResolution) { RefreshSizes(); GameViewSize gvs = sizes.FirstOrDefault((o) => o.width == width && o.height == height); if (gvs == null) { string name = (config != null) ? config.Name : ResolutionMonitor.Instance.FallbackName; AddSizeToUnity(name, width, height); gvs = sizes.FirstOrDefault((o) => o.width == width && o.height == height); } if (gvs != null) { SetResolution(gvs); } } } }; if (GUILayout.Button(ResolutionMonitor.Instance.FallbackName + " (Fallback)", style)) { var resolution = ResolutionMonitor.OptimizedResolutionFallback; applyScreenConfig(null, (int)resolution.x, (int)resolution.y); } EditorGUILayout.Space(); foreach (var config in ResolutionMonitor.Instance.OptimizedScreens) { if (GUILayout.Button(ResolutionMonitorEditor.GetButtonText(config), style)) { applyScreenConfig(config, config.OptimizedWidth, config.OptimizedHeight); } } GUILayout.FlexibleSpace(); End(mainSection: true); } End(mainSection: false); style.alignment = prevAlign; }
public static bool Contains(GameViewSizeGroupType groupType, GameViewSize gameViewSize) { _gameViewSize = gameViewSize; return(Contains(GetGroup(groupType, instance))); }
public static bool RemoveCustomSize(GameViewSizeGroupType groupType, GameViewSize gameViewSize) { _gameViewSize = gameViewSize; return(Remove(GetGroup(groupType, instance))); }