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();
                }
            }
        }
Пример #2
0
 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));
             }
         }
     }
 }
Пример #3
0
 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();
             }
         }
     }
 }
        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();
            }
        }
Пример #5
0
        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();
            }
        }