private void ResetSettingsFromBackend() { m_TargetSettings = null; if (targets.Length > 0) { List <BuildPlatform> validPlatforms = BuildPlatforms.instance.GetValidPlatforms(); m_TargetSettings = new InspectorTargetSettings[targets.Length, validPlatforms.Count + 1]; for (int i = 0; i < targets.Length; i++) { VideoClipImporter clipImporter = (VideoClipImporter)targets[i]; m_TargetSettings[i, 0] = new InspectorTargetSettings(); m_TargetSettings[i, 0].overridePlatform = true; m_TargetSettings[i, 0].settings = clipImporter.defaultTargetSettings; for (int j = 1; j < validPlatforms.Count + 1; j++) { BuildTargetGroup platformGroup = validPlatforms[j - 1].targetGroup; m_TargetSettings[i, j] = new InspectorTargetSettings(); m_TargetSettings[i, j].settings = clipImporter.Internal_GetTargetSettings(platformGroup); // We need to use this flag, and the nullity of the settings to determine if // we have an override. This is because we could create an override later during a toggle // and we want to keep that override even if we untoggle (to not lose the changes made) m_TargetSettings[i, j].overridePlatform = m_TargetSettings[i, j].settings != null; } } } m_ModifiedTargetSettings = false; }
private void ResetSettingsFromBackend() { this.m_TargetSettings = null; if (base.targets.Length > 0) { List <BuildPlatform> validPlatforms = BuildPlatforms.instance.GetValidPlatforms(); this.m_TargetSettings = new VideoClipImporterInspector.InspectorTargetSettings[base.targets.Length, validPlatforms.Count + 1]; for (int i = 0; i < base.targets.Length; i++) { VideoClipImporter videoClipImporter = (VideoClipImporter)base.targets[i]; this.m_TargetSettings[i, 0] = new VideoClipImporterInspector.InspectorTargetSettings(); this.m_TargetSettings[i, 0].overridePlatform = true; this.m_TargetSettings[i, 0].settings = videoClipImporter.defaultTargetSettings; for (int j = 1; j < validPlatforms.Count + 1; j++) { BuildTargetGroup targetGroup = validPlatforms[j - 1].targetGroup; this.m_TargetSettings[i, j] = new VideoClipImporterInspector.InspectorTargetSettings(); this.m_TargetSettings[i, j].settings = videoClipImporter.Internal_GetTargetSettings(targetGroup); this.m_TargetSettings[i, j].overridePlatform = (this.m_TargetSettings[i, j].settings != null); } } } this.m_ModifiedTargetSettings = false; }
public override void OnPreviewGUI(Rect r, GUIStyle background) { VideoClipImporter importer = (VideoClipImporter)target; if (m_IsPlaying && !importer.isPlayingPreview) { importer.PlayPreview(); } else if (!m_IsPlaying && importer.isPlayingPreview) { importer.StopPreview(); } Texture image = importer.GetPreviewTexture(); if (image && image.width != 0 && image.height != 0) { m_Texture = image; } if (!m_Texture) { return; } if (Event.current.type == EventType.Repaint) { background.Draw(r, false, false, false, false); } // Compensate spatial quality zooming, if any. float previewWidth = m_Texture.width; float previewHeight = m_Texture.height; var activeSettings = importer.Internal_GetTargetSettings(BuildPipeline.GetBuildTargetGroup(EditorUserBuildSettings.activeBuildTarget)); if (activeSettings == null) { activeSettings = importer.defaultTargetSettings; } if (activeSettings.enableTranscoding) { VideoResizeMode resizeMode = activeSettings.resizeMode; previewWidth = importer.GetResizeWidth(resizeMode); previewHeight = importer.GetResizeHeight(resizeMode); } if (importer.pixelAspectRatioDenominator > 0) { float pixelAspectRatio = (float)importer.pixelAspectRatioNumerator / (float)importer.pixelAspectRatioDenominator; if (pixelAspectRatio > 1.0F) { previewWidth *= pixelAspectRatio; } else { previewHeight /= pixelAspectRatio; } } float zoomLevel = 1.0f; if ((r.width / previewWidth * previewHeight) > r.height) { zoomLevel = r.height / previewHeight; } else { zoomLevel = r.width / previewWidth; } zoomLevel = Mathf.Clamp01(zoomLevel); Rect wantedRect = new Rect(r.x, r.y, previewWidth * zoomLevel, previewHeight * zoomLevel); PreviewGUI.BeginScrollView( r, m_Position, wantedRect, "PreHorizontalScrollbar", "PreHorizontalScrollbarThumb"); EditorGUI.DrawTextureTransparent(wantedRect, m_Texture, ScaleMode.StretchToFill); m_Position = PreviewGUI.EndScrollView(); if (m_IsPlaying && Event.current.type == EventType.Repaint) { GUIView.current.Repaint(); } }