private void OnCrossTargetInspectorGUI() { bool flag = true; bool flag2 = true; for (int i = 0; i < base.targets.Length; i++) { VideoClipImporter videoClipImporter = (VideoClipImporter)base.targets[i]; flag &= videoClipImporter.sourceHasAlpha; flag2 &= (videoClipImporter.sourceAudioTrackCount > 0); } if (flag) { EditorGUILayout.PropertyField(this.m_EncodeAlpha, VideoClipImporterInspector.s_Styles.keepAlphaContent, new GUILayoutOption[0]); } EditorGUILayout.PropertyField(this.m_Deinterlace, VideoClipImporterInspector.s_Styles.deinterlaceContent, new GUILayoutOption[0]); EditorGUILayout.Space(); EditorGUILayout.PropertyField(this.m_FlipHorizontal, VideoClipImporterInspector.s_Styles.flipHorizontalContent, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_FlipVertical, VideoClipImporterInspector.s_Styles.flipVerticalContent, new GUILayoutOption[0]); EditorGUILayout.Space(); using (new EditorGUI.DisabledScope(!flag2)) { EditorGUILayout.PropertyField(this.m_ImportAudio, VideoClipImporterInspector.s_Styles.importAudioContent, new GUILayoutOption[0]); } }
public override void OnInspectorGUI() { base.serializedObject.UpdateIfRequiredOrScript(); if (this.m_UseLegacyImporter.boolValue) { EditorGUILayout.PropertyField(this.m_IsColorLinear, MovieImporterInspector.linearTextureContent, new GUILayoutOption[0]); EditorGUILayout.Slider(this.m_Quality, 0f, 1f, new GUILayoutOption[0]); } else { this.OnCrossTargetInspectorGUI(); EditorGUILayout.Space(); this.OnTargetsInspectorGUI(); if (this.AnySettingsNotTranscoded()) { EditorGUILayout.HelpBox(VideoClipImporterInspector.s_Styles.transcodeWarning.text, MessageType.Info); } } UnityEngine.Object[] targets = base.targets; for (int i = 0; i < targets.Length; i++) { UnityEngine.Object @object = targets[i]; VideoClipImporter videoClipImporter = @object as VideoClipImporter; if (videoClipImporter && videoClipImporter.transcodeSkipped) { EditorGUILayout.HelpBox((base.targets.Length != 1) ? VideoClipImporterInspector.s_Styles.multipleTranscodeSkippedWarning.text : VideoClipImporterInspector.s_Styles.transcodeSkippedWarning.text, MessageType.Error); break; } } base.ApplyRevertGUI(); }
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 OnCrossTargetInspectorGUI() { bool sourcesHaveAlpha = true; bool sourcesHaveAudio = true; for (int i = 0; i < targets.Length; ++i) { VideoClipImporter importer = (VideoClipImporter)targets[i]; sourcesHaveAlpha &= importer.sourceHasAlpha; sourcesHaveAudio &= (importer.sourceAudioTrackCount > 0); } if (sourcesHaveAlpha) { EditorGUILayout.PropertyField(m_EncodeAlpha, s_Styles.keepAlphaContent); } EditorGUILayout.PropertyField(m_Deinterlace, s_Styles.deinterlaceContent); EditorGUILayout.Space(); EditorGUILayout.PropertyField(m_FlipHorizontal, s_Styles.flipHorizontalContent); EditorGUILayout.PropertyField(m_FlipVertical, s_Styles.flipVerticalContent); EditorGUILayout.Space(); using (new EditorGUI.DisabledScope(!sourcesHaveAudio)) { EditorGUILayout.PropertyField(m_ImportAudio, s_Styles.importAudioContent); } }
private void WriteSettingsToBackend() { if (this.m_TargetSettings != null) { List <BuildPlayerWindow.BuildPlatform> validPlatforms = BuildPlayerWindow.GetValidPlatforms(); for (int i = 0; i < base.targets.Length; i++) { VideoClipImporter videoClipImporter = (VideoClipImporter)base.targets[i]; videoClipImporter.defaultTargetSettings = this.m_TargetSettings[i, 0].settings; for (int j = 1; j < validPlatforms.Count + 1; j++) { BuildTargetGroup targetGroup = validPlatforms[j - 1].targetGroup; if (this.m_TargetSettings[i, j].settings != null && this.m_TargetSettings[i, j].overridePlatform) { videoClipImporter.Internal_SetTargetSettings(targetGroup, this.m_TargetSettings[i, j].settings); } else { videoClipImporter.Internal_ClearTargetSettings(targetGroup); } } } } this.m_ModifiedTargetSettings = false; }
public override void OnInspectorGUI() { serializedObject.Update(); extraDataSerializedObject.Update(); OnCrossTargetInspectorGUI(); EditorGUILayout.Space(); OnTargetsInspectorGUI(); // Warn the user if there is no transcoding happening on at least one platform if (AnySettingsNotTranscoded()) { EditorGUILayout.HelpBox(s_Styles.transcodeWarning.text, MessageType.Info); } foreach (var t in targets) { VideoClipImporter importer = t as VideoClipImporter; if (importer && importer.transcodeSkipped) { EditorGUILayout.HelpBox( targets.Length == 1 ? s_Styles.transcodeSkippedWarning.text : s_Styles.multipleTranscodeSkippedWarning.text, MessageType.Error); break; } } extraDataSerializedObject.ApplyModifiedProperties(); serializedObject.ApplyModifiedProperties(); ApplyRevertGUI(); }
private string GetAudioTrackDescription(VideoClipImporter importer, ushort audioTrackIdx) { ushort sourceAudioChannelCount = importer.GetSourceAudioChannelCount(audioTrackIdx); string arg = (sourceAudioChannelCount != 0) ? ((sourceAudioChannelCount != 1) ? ((sourceAudioChannelCount != 2) ? ((sourceAudioChannelCount != 4) ? (((int)(sourceAudioChannelCount - 1)).ToString() + ".1") : sourceAudioChannelCount.ToString()) : "Stereo") : "Mono") : "No channels"; return(importer.GetSourceAudioSampleRate(audioTrackIdx) + " Hz, " + arg); }
private void WriteSettingsToBackend() { if (m_TargetSettings != null) { List <BuildPlatform> validPlatforms = BuildPlatforms.instance.GetValidPlatforms(); for (int i = 0; i < targets.Length; i++) { VideoClipImporter clipImporter = (VideoClipImporter)targets[i]; clipImporter.defaultTargetSettings = m_TargetSettings[i, 0].settings; for (int j = 1; j < validPlatforms.Count + 1; j++) { BuildTargetGroup platformGroup = validPlatforms[j - 1].targetGroup; if (m_TargetSettings[i, j].settings != null && m_TargetSettings[i, j].overridePlatform) { clipImporter.Internal_SetTargetSettings(platformGroup, m_TargetSettings[i, j].settings); } else { clipImporter.Internal_ClearTargetSettings(platformGroup); } } } } m_ModifiedTargetSettings = false; }
public override void OnEnable() { base.OnEnable(); m_EncodeAlpha = serializedObject.FindProperty("m_EncodeAlpha"); m_Deinterlace = serializedObject.FindProperty("m_Deinterlace"); m_FlipVertical = serializedObject.FindProperty("m_FlipVertical"); m_FlipHorizontal = serializedObject.FindProperty("m_FlipHorizontal"); m_ImportAudio = serializedObject.FindProperty("m_ImportAudio"); m_ColorSpace = serializedObject.FindProperty("m_ColorSpace"); // setup alpha and audio values m_SourcesHaveAlpha = true; m_SourcesHaveAudio = true; if (assetTarget != null) { for (int i = 0; i < targets.Length; ++i) { VideoClipImporter importer = (VideoClipImporter)targets[i]; m_SourcesHaveAlpha &= importer.sourceHasAlpha; m_SourcesHaveAudio &= (importer.sourceAudioTrackCount > 0); } } m_ShowResizeModeOptions.valueChanged.AddListener(Repaint); var defaultResizeMode = extraDataSerializedObject.FindProperty("allSettings.Array.data[0].settings.resizeMode"); m_ShowResizeModeOptions.value = defaultResizeMode.hasMultipleDifferentValues || (VideoResizeMode)defaultResizeMode.intValue != VideoResizeMode.OriginalSize; }
public override void OnPreviewSettings() { VideoClipImporter importer = (VideoClipImporter)target; EditorGUI.BeginDisabledGroup(Application.isPlaying); m_IsPlaying = PreviewGUI.CycleButton(m_IsPlaying ? 1 : 0, s_Styles.playIcons) != 0; EditorGUI.EndDisabledGroup(); }
public override void OnPreviewSettings() { VideoClipImporter videoClipImporter = (VideoClipImporter)base.target; EditorGUI.BeginDisabledGroup(Application.isPlaying || this.HasModified() || videoClipImporter.useLegacyImporter); this.m_IsPlaying = (PreviewGUI.CycleButton((!this.m_IsPlaying) ? 0 : 1, VideoClipImporterInspector.s_Styles.playIcons) != 0); EditorGUI.EndDisabledGroup(); }
public override void OnDisable() { VideoClipImporter importer = target as VideoClipImporter; if (importer) { importer.StopPreview(); } base.OnDisable(); }
public override void OnPreviewGUI(Rect r, GUIStyle background) { bool flag = Event.current.type == EventType.Repaint; if (flag) { background.Draw(r, false, false, false, false); } VideoClipImporter videoClipImporter = (VideoClipImporter)base.target; if (this.m_IsPlaying && !videoClipImporter.isPlayingPreview) { videoClipImporter.PlayPreview(); } else if (!this.m_IsPlaying && videoClipImporter.isPlayingPreview) { videoClipImporter.StopPreview(); } Texture previewTexture = videoClipImporter.GetPreviewTexture(); if (previewTexture && previewTexture.width != 0 && previewTexture.height != 0) { float num = (float)previewTexture.width; float num2 = (float)previewTexture.height; if (videoClipImporter.defaultTargetSettings.enableTranscoding) { VideoResizeMode resizeMode = videoClipImporter.defaultTargetSettings.resizeMode; num = (float)videoClipImporter.GetResizeWidth(resizeMode); num2 = (float)videoClipImporter.GetResizeHeight(resizeMode); } if (videoClipImporter.pixelAspectRatioDenominator > 0) { num *= (float)videoClipImporter.pixelAspectRatioNumerator / (float)videoClipImporter.pixelAspectRatioDenominator; } float num3; if (r.width / num * num2 > r.height) { num3 = r.height / num2; } else { num3 = r.width / num; } num3 = Mathf.Clamp01(num3); Rect rect = new Rect(r.x, r.y, num * num3, num2 * num3); PreviewGUI.BeginScrollView(r, this.m_Position, rect, "PreHorizontalScrollbar", "PreHorizontalScrollbarThumb"); EditorGUI.DrawTextureTransparent(rect, previewTexture, ScaleMode.StretchToFill); this.m_Position = PreviewGUI.EndScrollView(); if (this.m_IsPlaying && flag) { GUIView.current.Repaint(); } } }
private string GetAudioTrackDescription(VideoClipImporter importer, ushort audioTrackIdx) { var channelCount = importer.GetSourceAudioChannelCount(audioTrackIdx); string channelCountStr = channelCount == 0 ? "No channels" : channelCount == 1 ? "Mono" : channelCount == 2 ? "Stereo" : channelCount == 4 ? channelCount.ToString() : // Can be 3.1 or quad ((channelCount - 1).ToString() + ".1"); return(importer.GetSourceAudioSampleRate(audioTrackIdx) + " Hz, " + channelCountStr); }
public override void OnPreviewGUI(Rect r, GUIStyle background) { if (Event.current.type == EventType.Repaint) { VideoClipImporter videoClipImporter = (VideoClipImporter)this.target; RectOffset rectOffset = new RectOffset(-5, -5, -5, -5); r = rectOffset.Add(r); r.height = EditorGUIUtility.singleLineHeight; Rect rect = r; Rect rect2 = r; rect.width = 120f; rect2.xMin += 120f; rect2.width = 200f; this.ShowProperty(ref rect, ref rect2, "Original Size", EditorUtility.FormatBytes((long)videoClipImporter.sourceFileSize)); this.ShowProperty(ref rect, ref rect2, "Imported Size", EditorUtility.FormatBytes((long)videoClipImporter.outputFileSize)); int frameCount = videoClipImporter.frameCount; double frameRate = videoClipImporter.frameRate; string arg_FD_0; if (frameRate > 0.0) { arg_FD_0 = TimeSpan.FromSeconds((double)frameCount / frameRate).ToString(); } else { TimeSpan timeSpan = new TimeSpan(0L); arg_FD_0 = timeSpan.ToString(); } string text = arg_FD_0; if (text.IndexOf('.') != -1) { text = text.Substring(0, text.Length - 4); } this.ShowProperty(ref rect, ref rect2, "Duration", text); this.ShowProperty(ref rect, ref rect2, "Frames", frameCount.ToString()); this.ShowProperty(ref rect, ref rect2, "FPS", frameRate.ToString("F2")); int resizeWidth = videoClipImporter.GetResizeWidth(VideoResizeMode.OriginalSize); int resizeHeight = videoClipImporter.GetResizeHeight(VideoResizeMode.OriginalSize); this.ShowProperty(ref rect, ref rect2, "Pixels", resizeWidth + "x" + resizeHeight); this.ShowProperty(ref rect, ref rect2, "PAR", videoClipImporter.pixelAspectRatioNumerator + ":" + videoClipImporter.pixelAspectRatioDenominator); this.ShowProperty(ref rect, ref rect2, "Alpha", (!videoClipImporter.sourceHasAlpha) ? "No" : "Yes"); ushort sourceAudioTrackCount = videoClipImporter.sourceAudioTrackCount; this.ShowProperty(ref rect, ref rect2, "Audio", (sourceAudioTrackCount != 0) ? ((sourceAudioTrackCount != 1) ? "" : this.GetAudioTrackDescription(videoClipImporter, 0)) : "none"); if (sourceAudioTrackCount > 1) { rect.xMin += 30f; rect.width -= 30f; for (ushort num = 0; num < sourceAudioTrackCount; num += 1) { this.ShowProperty(ref rect, ref rect2, "Track #" + (int)(num + 1), this.GetAudioTrackDescription(videoClipImporter, num)); } } } }
private List <GUIContent> GetResizeModeList() { var resizeModeList = new List <GUIContent>(); VideoClipImporter importer = (VideoClipImporter)target; foreach (VideoResizeMode mode in System.Enum.GetValues(typeof(VideoResizeMode))) { resizeModeList.Add(EditorGUIUtility.TextContent(importer.GetResizeModeName(mode))); } return(resizeModeList); }
private void OnCrossTargetInspectorGUI() { bool sourcesHaveAlpha = true; bool sourcesHaveAudio = true; for (int i = 0; i < targets.Length; ++i) { VideoClipImporter importer = (VideoClipImporter)targets[i]; sourcesHaveAlpha &= importer.sourceHasAlpha; sourcesHaveAudio &= (importer.sourceAudioTrackCount > 0); } EditorGUI.BeginChangeCheck(); var sRGB = EditorGUILayout.Toggle(s_Styles.sRGBTextureContent, m_ColorSpace.enumValueIndex == (int)VideoColorSpace.sRGB); if (EditorGUI.EndChangeCheck()) { m_ColorSpace.enumValueIndex = (int)(sRGB ? VideoColorSpace.sRGB : VideoColorSpace.Linear); } EditorGUILayout.Space(); EditorGUILayout.LabelField(s_Styles.globalTranscodeOptionsContent, EditorStyles.boldLabel); EditorGUI.indentLevel++; if (sourcesHaveAlpha) { EditorGUILayout.PropertyField(m_EncodeAlpha, s_Styles.keepAlphaContent); EditorGUILayout.Space(); } EditorGUILayout.PropertyField(m_Deinterlace, s_Styles.deinterlaceContent); EditorGUILayout.Space(); EditorGUILayout.PropertyField(m_FlipHorizontal, s_Styles.flipHorizontalContent); EditorGUILayout.PropertyField(m_FlipVertical, s_Styles.flipVerticalContent); EditorGUILayout.Space(); using (new EditorGUI.DisabledScope(!sourcesHaveAudio)) { EditorGUILayout.PropertyField(m_ImportAudio, s_Styles.importAudioContent); } EditorGUI.indentLevel--; }
public override void OnPreviewGUI(Rect r, GUIStyle background) { if (Event.current.type == EventType.Repaint) { background.Draw(r, false, false, false, false); VideoClipImporter videoClipImporter = (VideoClipImporter)base.target; if (this.m_IsPlaying && !videoClipImporter.isPlayingPreview) { videoClipImporter.PlayPreview(); } else if (!this.m_IsPlaying && videoClipImporter.isPlayingPreview) { videoClipImporter.StopPreview(); } Texture previewTexture = videoClipImporter.GetPreviewTexture(); if (previewTexture && previewTexture.width != 0 && previewTexture.height != 0) { float num = 1f; float num2 = 1f; if (videoClipImporter.defaultTargetSettings.enableTranscoding) { VideoResizeMode resizeMode = videoClipImporter.defaultTargetSettings.resizeMode; num = (float)(videoClipImporter.GetResizeWidth(resizeMode) / previewTexture.width); num2 = (float)(videoClipImporter.GetResizeHeight(resizeMode) / previewTexture.height); } float num3 = Mathf.Min(new float[] { num *r.width / (float)previewTexture.width, num2 * r.height / (float)previewTexture.height, num, num2 }); Rect rect = new Rect(r.x, r.y, (float)previewTexture.width * num3, (float)previewTexture.height * num3); PreviewGUI.BeginScrollView(r, this.m_Position, rect, "PreHorizontalScrollbar", "PreHorizontalScrollbarThumb"); EditorGUI.DrawTextureTransparent(rect, previewTexture, ScaleMode.StretchToFill); this.m_Position = PreviewGUI.EndScrollView(); if (this.m_IsPlaying) { GUIView.current.Repaint(); } } } }
internal override void OnHeaderControlsGUI() { serializedObject.UpdateIfRequiredOrScript(); bool supportsLegacy = true; for (int i = 0; supportsLegacy && i < targets.Length; ++i) { VideoClipImporter importer = (VideoClipImporter)targets[i]; supportsLegacy &= IsFileSupportedByLegacy(importer.assetPath); } if (!supportsLegacy) { base.OnHeaderControlsGUI(); return; } EditorGUI.showMixedValue = m_UseLegacyImporter.hasMultipleDifferentValues; EditorGUI.BeginChangeCheck(); var originalLabelWidth = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = 100; int selectionIndex = EditorGUILayout.Popup( s_Styles.importerVersionContent, m_UseLegacyImporter.boolValue ? 1 : 0, s_Styles.importerVersionOptions, EditorStyles.popup, GUILayout.MaxWidth(230)); EditorGUIUtility.labelWidth = originalLabelWidth; EditorGUI.showMixedValue = false; if (EditorGUI.EndChangeCheck()) { m_UseLegacyImporter.boolValue = selectionIndex == 1; } serializedObject.ApplyModifiedProperties(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Open", EditorStyles.miniButton)) { AssetDatabase.OpenAsset(assetTargets); GUIUtility.ExitGUI(); } }
public override void OnInspectorGUI() { serializedObject.Update(); if (m_UseLegacyImporter.boolValue) { #pragma warning disable 0618 EditorGUILayout.PropertyField( m_IsColorLinear, MovieImporterInspector.linearTextureContent); EditorGUILayout.Slider(m_Quality, 0.0f, 1.0f); #pragma warning restore 0618 } else { OnCrossTargetInspectorGUI(); EditorGUILayout.Space(); OnTargetsInspectorGUI(); // Warn the user if there is no transcoding happening on at least one platform if (AnySettingsNotTranscoded()) { EditorGUILayout.HelpBox(s_Styles.transcodeWarning.text, MessageType.Info); } } foreach (var t in targets) { VideoClipImporter importer = t as VideoClipImporter; if (importer && importer.transcodeSkipped) { EditorGUILayout.HelpBox( targets.Length == 1 ? s_Styles.transcodeSkippedWarning.text : s_Styles.multipleTranscodeSkippedWarning.text, MessageType.Error); break; } } serializedObject.ApplyModifiedProperties(); ApplyRevertGUI(); }
internal override void OnHeaderControlsGUI() { base.serializedObject.UpdateIfRequiredOrScript(); bool flag = true; int num = 0; while (flag && num < base.targets.Length) { VideoClipImporter videoClipImporter = (VideoClipImporter)base.targets[num]; flag &= this.IsFileSupportedByLegacy(videoClipImporter.assetPath); num++; } if (!flag) { base.OnHeaderControlsGUI(); } else { EditorGUI.showMixedValue = this.m_UseLegacyImporter.hasMultipleDifferentValues; EditorGUI.BeginChangeCheck(); float labelWidth = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = 100f; int num2 = EditorGUILayout.Popup(VideoClipImporterInspector.s_Styles.importerVersionContent, (!this.m_UseLegacyImporter.boolValue) ? 0 : 1, VideoClipImporterInspector.s_Styles.importerVersionOptions, EditorStyles.popup, new GUILayoutOption[] { GUILayout.MaxWidth(230f) }); EditorGUIUtility.labelWidth = labelWidth; EditorGUI.showMixedValue = false; if (EditorGUI.EndChangeCheck()) { this.m_UseLegacyImporter.boolValue = (num2 == 1); } GUILayout.FlexibleSpace(); if (GUILayout.Button("Open", EditorStyles.miniButton, new GUILayoutOption[0])) { AssetDatabase.OpenAsset(base.assetTargets); GUIUtility.ExitGUI(); } } }
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; }
private List <GUIContent> GetResizeModeList() { List <GUIContent> list = new List <GUIContent>(); VideoClipImporter videoClipImporter = (VideoClipImporter)base.target; IEnumerator enumerator = Enum.GetValues(typeof(VideoResizeMode)).GetEnumerator(); try { while (enumerator.MoveNext()) { VideoResizeMode mode = (VideoResizeMode)enumerator.Current; list.Add(EditorGUIUtility.TextContent(videoClipImporter.GetResizeModeName(mode))); } } finally { IDisposable disposable; if ((disposable = (enumerator as IDisposable)) != null) { disposable.Dispose(); } } return(list); }
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.GetTargetSettings(BuildPipeline.GetBuildTargetGroup(EditorUserBuildSettings.activeBuildTarget).ToString()); 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(); } }
public uint GetSourceAudioSampleRate(ushort audioTrackIdx) { return(VideoClipImporter.INTERNAL_CALL_GetSourceAudioSampleRate(this, audioTrackIdx)); }
public override bool HasPreviewGUI() { VideoClipImporter videoClipImporter = this.target as VideoClipImporter; return(videoClipImporter != null && !videoClipImporter.useLegacyImporter); }
private extern static ushort INTERNAL_CALL_GetSourceAudioChannelCount(VideoClipImporter self, ushort audioTrackIdx);
private extern static uint INTERNAL_CALL_GetSourceAudioSampleRate(VideoClipImporter self, ushort audioTrackIdx);
extern public bool Equals(VideoClipImporter rhs);
public override void OnPreviewGUI(Rect r, GUIStyle background) { var isRepainting = Event.current.type == EventType.Repaint; if (isRepainting) { background.Draw(r, false, false, false, false); } 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) { return; } // Compensate spatial quality zooming, if any. float previewWidth = image.width; float previewHeight = image.height; if (importer.defaultTargetSettings.enableTranscoding) { VideoResizeMode resizeMode = importer.defaultTargetSettings.resizeMode; previewWidth = importer.GetResizeWidth(resizeMode); previewHeight = importer.GetResizeHeight(resizeMode); } if (importer.pixelAspectRatioDenominator > 0) { previewWidth *= (float)importer.pixelAspectRatioNumerator / (float)importer.pixelAspectRatioDenominator; } 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, image, ScaleMode.StretchToFill); m_Position = PreviewGUI.EndScrollView(); if (m_IsPlaying && isRepainting) { GUIView.current.Repaint(); } }