EndScrollView() public static method

public static EndScrollView ( ) : Vector2
return Vector2
Ejemplo n.º 1
0
        public override void OnPreviewGUI(Rect r, GUIStyle background)
        {
            if (Event.current.type == EventType.Repaint)
            {
                background.Draw(r, false, false, false, false);
            }

            TerrainLayer terrainLayer = (TerrainLayer)target;

            Texture2D mask = terrainLayer.diffuseTexture;

            if (mask != null)
            {
                int texWidth  = Mathf.Min(mask.width, 256);
                int texHeight = Mathf.Min(mask.height, 256);

                float zoomLevel  = Mathf.Min(Mathf.Min(r.width / texWidth, r.height / texHeight), 1);
                Rect  wantedRect = new Rect(r.x, r.y, texWidth * zoomLevel, texHeight * zoomLevel);
                PreviewGUI.BeginScrollView(r, m_Pos, wantedRect, "PreHorizontalScrollbar", "PreHorizontalScrollbarThumb");

                EditorGUI.DrawPreviewTexture(wantedRect, mask);

                m_Pos = PreviewGUI.EndScrollView();
            }
        }
        public override void OnPreviewGUI(Rect r, GUIStyle background)
        {
            if (Event.current.type == EventType.Repaint)
            {
                background.Draw(r, false, false, false, false);
            }
            WebCamTexture webCamTexture = base.target as WebCamTexture;
            float         num           = Mathf.Min(Mathf.Min(r.width / (float)webCamTexture.width, r.height / (float)webCamTexture.height), 1f);
            Rect          rect          = new Rect(r.x, r.y, (float)webCamTexture.width * num, (float)webCamTexture.height * num);

            PreviewGUI.BeginScrollView(r, this.m_Pos, rect, "PreHorizontalScrollbar", "PreHorizontalScrollbarThumb");
            GUI.DrawTexture(rect, webCamTexture, ScaleMode.StretchToFill, false);
            this.m_Pos = PreviewGUI.EndScrollView();
            if (webCamTexture.isPlaying)
            {
                GUIView.current.Repaint();
            }
            if (Application.isPlaying)
            {
                if (webCamTexture.isPlaying)
                {
                    EditorGUI.DropShadowLabel(new Rect(r.x, r.y + 10f, r.width, 20f), "Can't pause preview when in play mode");
                }
                else
                {
                    EditorGUI.DropShadowLabel(new Rect(r.x, r.y + 10f, r.width, 20f), "Can't start preview when in play mode");
                }
            }
        }
        public override void OnPreviewGUI(Rect r, GUIStyle background)
        {
            if (Event.current.type == EventType.Repaint)
            {
                background.Draw(r, false, false, false, false);
            }
            MovieTexture target = this.target as MovieTexture;
            float        num    = Mathf.Min(Mathf.Min(r.width / (float)target.width, r.height / (float)target.height), 1f);
            Rect         rect   = new Rect(r.x, r.y, (float)target.width * num, (float)target.height * num);

            PreviewGUI.BeginScrollView(r, this.m_Pos, rect, (GUIStyle)"PreHorizontalScrollbar", (GUIStyle)"PreHorizontalScrollbarThumb");
            EditorGUI.DrawPreviewTexture(rect, (Texture)target, (Material)null, ScaleMode.StretchToFill);
            this.m_Pos = PreviewGUI.EndScrollView();
            if (target.isPlaying)
            {
                GUIView.current.Repaint();
            }
            if (!Application.isPlaying)
            {
                return;
            }
            if (target.isPlaying)
            {
                EditorGUI.DropShadowLabel(new Rect(r.x, r.y + 10f, r.width, 20f), "Can't pause preview when in play mode");
            }
            else
            {
                EditorGUI.DropShadowLabel(new Rect(r.x, r.y + 10f, r.width, 20f), "Can't start preview when in play mode");
            }
        }
        public override void OnPreviewGUI(Rect r, GUIStyle background)
        {
            if (Event.current.type == EventType.Repaint)
            {
                background.Draw(r, false, false, false, false);
            }

            // show texture
            WebCamTexture t = target as WebCamTexture;

            float zoomLevel  = Mathf.Min(Mathf.Min(r.width / t.width, r.height / t.height), 1);
            Rect  wantedRect = new Rect(r.x, r.y, t.width * zoomLevel, t.height * zoomLevel);

            PreviewGUI.BeginScrollView(r, m_Pos, wantedRect, "PreHorizontalScrollbar", "PreHorizontalScrollbarThumb");
            GUI.DrawTexture(wantedRect, t, ScaleMode.StretchToFill, false);
            m_Pos = PreviewGUI.EndScrollView();

            // force update GUI
            if (t.isPlaying)
            {
                GUIView.current.Repaint();
            }

            if (Application.isPlaying)
            {
                if (t.isPlaying)
                {
                    EditorGUI.DropShadowLabel(new Rect(r.x, r.y + 10, r.width, 20), "Can't pause preview when in play mode");
                }
                else
                {
                    EditorGUI.DropShadowLabel(new Rect(r.x, r.y + 10, r.width, 20), "Can't start preview when in play mode");
                }
            }
        }
Ejemplo n.º 5
0
        public override void OnPreviewGUI(Rect r, GUIStyle background)
        {
            if (Event.current.type == EventType.Repaint)
            {
                background.Draw(r, false, false, false, false);
            }

            Texture2D mask = (Texture2D)m_DiffuseTexture.objectReferenceValue;

            if (mask == null)
            {
                mask         = EditorGUIUtility.whiteTexture;
                m_HasChanged = true;
            }

            int texWidth  = Mathf.Min(mask.width, 256);
            int texHeight = Mathf.Min(mask.height, 256);

            float zoomLevel  = Mathf.Min(Mathf.Min(r.width / texWidth, r.height / texHeight), 1);
            Rect  wantedRect = new Rect(r.x, r.y, texWidth * zoomLevel, texHeight * zoomLevel);

            PreviewGUI.BeginScrollView(r, m_Pos, wantedRect, "PreHorizontalScrollbar", "PreHorizontalScrollbarThumb");

            EditorGUI.DrawPreviewTexture(wantedRect, mask);

            m_Pos = PreviewGUI.EndScrollView();
        }
        public override void OnPreviewGUI(Rect r, GUIStyle background)
        {
            if (!SystemInfo.supports2DArrayTextures)
            {
                if (Event.current.type == EventType.Repaint)
                {
                    EditorGUI.DropShadowLabel(new Rect(r.x, r.y, r.width, 40), "2D texture array preview not supported");
                }
                return;
            }

            Texture2DArray t = (Texture2DArray)target;

            Rect scrubberRect = r;

            scrubberRect.height = kScrubberHeight;
            r.yMin += kScrubberHeight + kScrubberMargin;

            DoSliceScrubber(scrubberRect, t);

            if (Event.current.type == EventType.Repaint)
            {
                InitPreview();
                m_Material.mainTexture = t;

                // If multiple objects are selected, we might be using a slice level before the maximum
                int effectiveSlice = Mathf.Clamp(m_Slice, 0, t.depth - 1);

                m_Material.SetInt("_SliceIndex", effectiveSlice);
                m_Material.SetInt("_AlphaOnly", showAlpha ? 1 : 0);

                int texWidth  = Mathf.Max(t.width, 1);
                int texHeight = Mathf.Max(t.height, 1);

                float effectiveMipLevel = GetMipLevelForRendering();
                float zoomLevel         = Mathf.Min(Mathf.Min(r.width / texWidth, r.height / texHeight), 1);
                Rect  wantedRect        = new Rect(r.x, r.y, texWidth * zoomLevel, texHeight * zoomLevel);
                PreviewGUI.BeginScrollView(r, m_Pos, wantedRect, "PreHorizontalScrollbar",
                                           "PreHorizontalScrollbarThumb");
                FilterMode oldFilter = t.filterMode;
                TextureUtil.SetFilterModeNoDirty(t, FilterMode.Point);

                EditorGUI.DrawPreviewTexture(wantedRect, t, m_Material, ScaleMode.StretchToFill, 0, effectiveMipLevel);

                TextureUtil.SetFilterModeNoDirty(t, oldFilter);

                m_Pos = PreviewGUI.EndScrollView();
                if (effectiveSlice != 0 || (int)effectiveMipLevel != 0)
                {
                    EditorGUI.DropShadowLabel(new Rect(r.x, r.y + 10, r.width, 30),
                                              "Slice " + effectiveSlice + "\nMip " + effectiveMipLevel);
                }
            }
        }
        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();
                }
            }
        }
Ejemplo n.º 8
0
        public override void OnPreviewGUI(Rect r, GUIStyle background)
        {
            if (m_Dimension.intValue == (int)UnityEngine.Rendering.TextureDimension.Tex2DArray)
            {
                if (!SystemInfo.supports2DArrayTextures)
                {
                    if (Event.current.type == EventType.Repaint)
                    {
                        EditorGUI.DropShadowLabel(new Rect(r.x, r.y, r.width, 40), "2D texture array preview not supported");
                    }
                    return;
                }

                RenderTexture rt = (RenderTexture)target;

                if (Event.current.type == EventType.Repaint)
                {
                    InitPreview();
                    m_Material.mainTexture = rt;

                    // If multiple objects are selected, we might be using a slice level before the maximum
                    int effectiveSlice = Mathf.Clamp(m_Slice, 0, rt.volumeDepth - 1);

                    m_Material.SetInt(s_ShaderSliceIndex, effectiveSlice);
                    m_Material.SetInt(s_ShaderToSrgb, QualitySettings.activeColorSpace == ColorSpace.Linear ? 1 : 0);

                    int texWidth  = Mathf.Max(rt.width, 1);
                    int texHeight = Mathf.Max(rt.height, 1);

                    float zoomLevel  = Mathf.Min(Mathf.Min(r.width / texWidth, r.height / texHeight), 1);
                    Rect  wantedRect = new Rect(r.x, r.y, texWidth * zoomLevel, texHeight * zoomLevel);
                    PreviewGUI.BeginScrollView(r, m_Pos, wantedRect, "PreHorizontalScrollbar", "PreHorizontalScrollbarThumb");
                    FilterMode oldFilter = rt.filterMode;
                    TextureUtil.SetFilterModeNoDirty(rt, FilterMode.Point);

                    EditorGUI.DrawPreviewTexture(wantedRect, rt, m_Material, ScaleMode.StretchToFill, 0, mipLevel);

                    TextureUtil.SetFilterModeNoDirty(rt, oldFilter);

                    m_Pos = PreviewGUI.EndScrollView();
                    if (effectiveSlice != 0 || (int)mipLevel != 0)
                    {
                        EditorGUI.DropShadowLabel(new Rect(r.x, r.y + 10, r.width, 30),
                                                  "Slice " + effectiveSlice + "\nMip " + mipLevel);
                    }
                }
            }
            else
            {
                base.OnPreviewGUI(r, background);
            }
        }
        public void OnPreviewGUI(Texture t, Rect r, GUIStyle background, float exposure, TextureInspector.PreviewMode previewMode, float mipLevel)
        {
            if (t == null)
            {
                return;
            }

            if (!SystemInfo.supports2DArrayTextures)
            {
                EditorGUI.DropShadowLabel(new Rect(r.x, r.y, r.width, 40), "2D texture array preview not supported");
                return;
            }

            InitPreviewMaterialIfNeeded();
            m_Material.mainTexture = t;

            int effectiveSlice = GetEffectiveSlice(t);

            m_Material.SetFloat(s_ShaderSliceIndex, (float)effectiveSlice);
            m_Material.SetFloat(s_ShaderToSrgb, QualitySettings.activeColorSpace == ColorSpace.Linear ? 1.0f : 0.0f);
            m_Material.SetFloat(s_ShaderIsNormalMap, TextureInspector.IsNormalMap(t) ? 1.0f : 0.0f);

            SetShaderColorMask(previewMode);

            int texWidth  = Mathf.Max(t.width, 1);
            int texHeight = Mathf.Max(t.height, 1);

            float effectiveMipLevel = GetMipLevelForRendering(t, mipLevel);
            float zoomLevel         = Mathf.Min(Mathf.Min(r.width / texWidth, r.height / texHeight), 1);
            Rect  wantedRect        = new Rect(r.x, r.y, texWidth * zoomLevel, texHeight * zoomLevel);

            PreviewGUI.BeginScrollView(r, m_Pos, wantedRect, "PreHorizontalScrollbar",
                                       "PreHorizontalScrollbarThumb");
            FilterMode oldFilter = t.filterMode;

            TextureUtil.SetFilterModeNoDirty(t, FilterMode.Point);

            EditorGUI.DrawPreviewTexture(wantedRect, t, m_Material, ScaleMode.StretchToFill, 0, effectiveMipLevel, UnityEngine.Rendering.ColorWriteMask.All, exposure);

            TextureUtil.SetFilterModeNoDirty(t, oldFilter);

            m_Pos = PreviewGUI.EndScrollView();
            if (effectiveSlice != 0 || (int)effectiveMipLevel != 0)
            {
                EditorGUI.DropShadowLabel(new Rect(r.x, r.y + 10, r.width, 30),
                                          "Slice " + effectiveSlice + "\nMip " + effectiveMipLevel);
            }
        }
Ejemplo n.º 10
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();
             }
         }
     }
 }
Ejemplo n.º 11
0
        public override void OnPreviewGUI(Rect r, GUIStyle background)
        {
            if (Event.current.type == EventType.Repaint)
            {
                background.Draw(r, false, false, false, false);
            }

            Texture2D mask = (Texture2D)m_Mask.objectReferenceValue;

            if (mask == null)
            {
                mask         = Brush.DefaultMask();
                m_HasChanged = true;
            }

            int texWidth  = Mathf.Min(mask.width, 256);
            int texHeight = Mathf.Min(mask.height, 256);

            if (m_HasChanged || m_PreviewTexture == null)
            {
                m_PreviewTexture = Brush.GenerateBrushTexture(mask, m_Falloff.animationCurveValue, m_RadiusScale.floatValue, m_BlackWhiteRemapMin.floatValue, m_BlackWhiteRemapMax.floatValue, m_InvertRemapRange.boolValue, texWidth, texHeight, true);
                m_HasChanged     = false;
            }

            float zoomLevel  = Mathf.Min(Mathf.Min(r.width / texWidth, r.height / texHeight), 1);
            Rect  wantedRect = new Rect(r.x, r.y, texWidth * zoomLevel, texHeight * zoomLevel);

            PreviewGUI.BeginScrollView(r, m_Pos, wantedRect, "PreHorizontalScrollbar", "PreHorizontalScrollbarThumb");

            if (m_PreviewTexture.alphaIsTransparency)
            {
                EditorGUI.DrawTextureTransparent(wantedRect, m_PreviewTexture);
            }
            else
            {
                EditorGUI.DrawPreviewTexture(wantedRect, m_PreviewTexture);
            }

            m_Pos = PreviewGUI.EndScrollView();
        }
Ejemplo n.º 12
0
        public override void OnPreviewGUI(Rect r, GUIStyle background)
        {
            VideoClip clip = target as VideoClip;

            Event evt = Event.current;

            if (evt.type != EventType.Repaint &&
                evt.type != EventType.Layout &&
                evt.type != EventType.Used)
            {
                switch (evt.type)
                {
                case EventType.MouseDown:
                {
                    if (r.Contains(evt.mousePosition))
                    {
                        if (m_PlayingClip != null)
                        {
                            if (m_PreviewID.Empty() || !VideoUtil.IsPreviewPlaying(m_PreviewID))
                            {
                                PlayPreview();
                            }
                            else
                            {
                                StopPreview();
                            }
                        }
                        evt.Use();
                    }
                }
                break;
                }
                return;
            }

            if (clip != m_PlayingClip)
            {
                StopPreview();
                m_PlayingClip = clip;
            }

            Texture image = null;

            if (!m_PreviewID.Empty() && VideoUtil.IsPreviewPlaying(m_PreviewID))
            {
                image = VideoUtil.GetPreviewTexture(m_PreviewID);
                if (image != null && m_UseAssetPreview)
                {
                    m_UseAssetPreview = false;
                }
            }
            else
            {
                image = GetAssetPreviewTexture();
            }

            if (image != null && 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);
            }

            float previewWidth  = m_Texture.width;
            float previewHeight = m_Texture.height;

            if (m_PlayingClip.pixelAspectRatioDenominator > 0)
            {
                float pixelAspectRatio = (float)m_PlayingClip.pixelAspectRatioNumerator /
                                         (float)m_PlayingClip.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 = !m_UseAssetPreview ? new Rect(r.x, r.y, previewWidth * zoomLevel, m_Texture.height * zoomLevel) : r;

            PreviewGUI.BeginScrollView(
                r, m_Position, wantedRect, "PreHorizontalScrollbar", "PreHorizontalScrollbarThumb");

            if (!m_UseAssetPreview)
            {
                EditorGUI.DrawTextureTransparent(wantedRect, m_Texture, ScaleMode.StretchToFill);
            }
            else
            {
                GUI.DrawTexture(wantedRect, m_Texture, ScaleMode.ScaleToFit);
            }

            m_Position = PreviewGUI.EndScrollView();

            if (!m_PreviewID.Empty() &&
                VideoUtil.IsPreviewPlaying(m_PreviewID) &&
                Event.current.type == EventType.Repaint)
            {
                GUIView.current.Repaint();
            }
        }
Ejemplo n.º 13
0
        public override void OnPreviewGUI(Rect r, GUIStyle background)
        {
            VideoClip videoClip = base.target as VideoClip;
            Event     current   = Event.current;

            if (current.type != EventType.Repaint && current.type != EventType.Layout && current.type != EventType.Used)
            {
                EventType type = current.type;
                if (type == EventType.MouseDown)
                {
                    if (r.Contains(current.mousePosition))
                    {
                        if (this.m_PlayingClip != null)
                        {
                            if (this.m_PreviewID.Empty() || !VideoUtil.IsPreviewPlaying(this.m_PreviewID))
                            {
                                this.PlayPreview();
                            }
                            else
                            {
                                this.StopPreview();
                            }
                        }
                        current.Use();
                    }
                }
            }
            else
            {
                bool flag  = true;
                bool flag2 = videoClip != this.m_PlayingClip || (!this.m_PreviewID.Empty() && VideoUtil.IsPreviewPlaying(this.m_PreviewID));
                if (videoClip != this.m_PlayingClip)
                {
                    this.StopPreview();
                    this.m_PlayingClip = videoClip;
                }
                Texture texture = null;
                if (!this.m_PreviewID.Empty())
                {
                    texture = VideoUtil.GetPreviewTexture(this.m_PreviewID);
                }
                if (texture == null || texture.width == 0 || texture.height == 0)
                {
                    texture = this.GetAssetPreviewTexture();
                    flag    = false;
                }
                if (!(texture == null) && texture.width != 0 && texture.height != 0)
                {
                    if (Event.current.type == EventType.Repaint)
                    {
                        background.Draw(r, false, false, false, false);
                    }
                    float num  = (float)texture.width;
                    float num2 = (float)texture.height;
                    if (this.m_PlayingClip.pixelAspectRatioDenominator > 0u)
                    {
                        num *= this.m_PlayingClip.pixelAspectRatioNumerator / this.m_PlayingClip.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 = (!flag) ? r : new Rect(r.x, r.y, num * num3, (float)texture.height * num3);
                    PreviewGUI.BeginScrollView(r, this.m_Position, rect, "PreHorizontalScrollbar", "PreHorizontalScrollbarThumb");
                    if (flag)
                    {
                        EditorGUI.DrawTextureTransparent(rect, texture, ScaleMode.StretchToFill);
                    }
                    else
                    {
                        GUI.DrawTexture(rect, texture, ScaleMode.ScaleToFit);
                    }
                    this.m_Position = PreviewGUI.EndScrollView();
                    if (flag2)
                    {
                        GUIView.current.Repaint();
                    }
                }
            }
        }
Ejemplo n.º 14
0
        public override void OnPreviewGUI(Rect r, GUIStyle background)
        {
            if (Event.current.type == EventType.Repaint)
            {
                background.Draw(r, false, false, false, false);
            }
            Texture texture = base.target as Texture;

            if (!(texture == null))
            {
                RenderTexture renderTexture = texture as RenderTexture;
                if (renderTexture != null)
                {
                    if (!SystemInfo.SupportsRenderTextureFormat(renderTexture.format))
                    {
                        return;
                    }
                    renderTexture.Create();
                }
                if (this.IsCubemap())
                {
                    this.m_CubemapPreview.OnPreviewGUI(texture, r, background);
                }
                else
                {
                    int   num  = Mathf.Max(texture.width, 1);
                    int   num2 = Mathf.Max(texture.height, 1);
                    float mipLevelForRendering = this.GetMipLevelForRendering();
                    float num3 = Mathf.Min(Mathf.Min(r.width / (float)num, r.height / (float)num2), 1f);
                    Rect  rect = new Rect(r.x, r.y, (float)num * num3, (float)num2 * num3);
                    PreviewGUI.BeginScrollView(r, this.m_Pos, rect, "PreHorizontalScrollbar", "PreHorizontalScrollbarThumb");
                    float mipMapBias = texture.mipMapBias;
                    TextureUtil.SetMipMapBiasNoDirty(texture, mipLevelForRendering - this.Log2((float)num / rect.width));
                    FilterMode filterMode = texture.filterMode;
                    TextureUtil.SetFilterModeNoDirty(texture, FilterMode.Point);
                    if (this.m_ShowAlpha)
                    {
                        EditorGUI.DrawTextureAlpha(rect, texture);
                    }
                    else
                    {
                        Texture2D texture2D = texture as Texture2D;
                        if (texture2D != null && texture2D.alphaIsTransparency)
                        {
                            EditorGUI.DrawTextureTransparent(rect, texture);
                        }
                        else
                        {
                            EditorGUI.DrawPreviewTexture(rect, texture);
                        }
                    }
                    if (rect.width > 32f && rect.height > 32f)
                    {
                        string           assetPath       = AssetDatabase.GetAssetPath(texture);
                        TextureImporter  textureImporter = AssetImporter.GetAtPath(assetPath) as TextureImporter;
                        SpriteMetaData[] array           = (!(textureImporter != null)) ? null : textureImporter.spritesheet;
                        if (array != null && textureImporter.spriteImportMode == SpriteImportMode.Multiple)
                        {
                            Rect rect2 = default(Rect);
                            Rect rect3 = default(Rect);
                            GUI.CalculateScaledTextureRects(rect, ScaleMode.StretchToFill, (float)texture.width / (float)texture.height, ref rect2, ref rect3);
                            int width  = texture.width;
                            int height = texture.height;
                            textureImporter.GetWidthAndHeight(ref width, ref height);
                            float num4 = (float)texture.width / (float)width;
                            HandleUtility.ApplyWireMaterial();
                            GL.PushMatrix();
                            GL.MultMatrix(Handles.matrix);
                            GL.Begin(1);
                            GL.Color(new Color(1f, 1f, 1f, 0.5f));
                            SpriteMetaData[] array2 = array;
                            for (int i = 0; i < array2.Length; i++)
                            {
                                SpriteMetaData spriteMetaData = array2[i];
                                Rect           rect4          = spriteMetaData.rect;
                                this.DrawRect(new Rect
                                {
                                    xMin = rect2.xMin + rect2.width * (rect4.xMin / (float)texture.width * num4),
                                    xMax = rect2.xMin + rect2.width * (rect4.xMax / (float)texture.width * num4),
                                    yMin = rect2.yMin + rect2.height * (1f - rect4.yMin / (float)texture.height * num4),
                                    yMax = rect2.yMin + rect2.height * (1f - rect4.yMax / (float)texture.height * num4)
                                });
                            }
                            GL.End();
                            GL.PopMatrix();
                        }
                    }
                    TextureUtil.SetMipMapBiasNoDirty(texture, mipMapBias);
                    TextureUtil.SetFilterModeNoDirty(texture, filterMode);
                    this.m_Pos = PreviewGUI.EndScrollView();
                    if (mipLevelForRendering != 0f)
                    {
                        EditorGUI.DropShadowLabel(new Rect(r.x, r.y, r.width, 20f), "Mip " + mipLevelForRendering);
                    }
                }
            }
        }
Ejemplo n.º 15
0
        public override void OnPreviewGUI(Rect r, GUIStyle background)
        {
            if (Event.current.type == EventType.Repaint)
            {
                background.Draw(r, false, false, false, false);
            }
            Texture       target   = base.target as Texture;
            RenderTexture texture2 = target as RenderTexture;

            if (texture2 != null)
            {
                if (!SystemInfo.SupportsRenderTextureFormat(texture2.format))
                {
                    return;
                }
                texture2.Create();
            }
            if (this.IsCubemap())
            {
                this.m_CubemapPreview.OnPreviewGUI(target, r, background);
            }
            else
            {
                int   num  = Mathf.Max(target.width, 1);
                int   num2 = Mathf.Max(target.height, 1);
                float mipLevelForRendering = this.GetMipLevelForRendering();
                float num4     = Mathf.Min(Mathf.Min((float)(r.width / ((float)num)), (float)(r.height / ((float)num2))), 1f);
                Rect  viewRect = new Rect(r.x, r.y, num * num4, num2 * num4);
                PreviewGUI.BeginScrollView(r, this.m_Pos, viewRect, "PreHorizontalScrollbar", "PreHorizontalScrollbarThumb");
                float mipMapBias = target.mipMapBias;
                TextureUtil.SetMipMapBiasNoDirty(target, mipLevelForRendering - this.Log2(((float)num) / viewRect.width));
                UnityEngine.FilterMode filterMode = target.filterMode;
                TextureUtil.SetFilterModeNoDirty(target, UnityEngine.FilterMode.Point);
                if (this.m_ShowAlpha)
                {
                    EditorGUI.DrawTextureAlpha(viewRect, target);
                }
                else
                {
                    Texture2D textured = target as Texture2D;
                    if ((textured != null) && textured.alphaIsTransparency)
                    {
                        EditorGUI.DrawTextureTransparent(viewRect, target);
                    }
                    else
                    {
                        EditorGUI.DrawPreviewTexture(viewRect, target);
                    }
                }
                if ((viewRect.width > 32f) && (viewRect.height > 32f))
                {
                    TextureImporter  atPath      = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(target)) as TextureImporter;
                    SpriteMetaData[] spritesheet = atPath?.spritesheet;
                    if ((spritesheet != null) && (atPath.spriteImportMode == SpriteImportMode.Multiple))
                    {
                        Rect outScreenRect = new Rect();
                        Rect outSourceRect = new Rect();
                        GUI.CalculateScaledTextureRects(viewRect, ScaleMode.StretchToFill, ((float)target.width) / ((float)target.height), ref outScreenRect, ref outSourceRect);
                        int width  = target.width;
                        int height = target.height;
                        atPath.GetWidthAndHeight(ref width, ref height);
                        float num8 = ((float)target.width) / ((float)width);
                        HandleUtility.ApplyWireMaterial();
                        GL.PushMatrix();
                        GL.MultMatrix(Handles.matrix);
                        GL.Begin(1);
                        GL.Color(new Color(1f, 1f, 1f, 0.5f));
                        foreach (SpriteMetaData data in spritesheet)
                        {
                            Rect rect  = data.rect;
                            Rect rect5 = new Rect {
                                xMin = outScreenRect.xMin + (outScreenRect.width * ((rect.xMin / ((float)target.width)) * num8)),
                                xMax = outScreenRect.xMin + (outScreenRect.width * ((rect.xMax / ((float)target.width)) * num8)),
                                yMin = outScreenRect.yMin + (outScreenRect.height * (1f - ((rect.yMin / ((float)target.height)) * num8))),
                                yMax = outScreenRect.yMin + (outScreenRect.height * (1f - ((rect.yMax / ((float)target.height)) * num8)))
                            };
                            this.DrawRect(rect5);
                        }
                        GL.End();
                        GL.PopMatrix();
                    }
                }
                TextureUtil.SetMipMapBiasNoDirty(target, mipMapBias);
                TextureUtil.SetFilterModeNoDirty(target, filterMode);
                this.m_Pos = PreviewGUI.EndScrollView();
                if (mipLevelForRendering != 0f)
                {
                    EditorGUI.DropShadowLabel(new Rect(r.x, r.y, r.width, 20f), "Mip " + mipLevelForRendering);
                }
            }
        }
Ejemplo n.º 16
0
        public override void OnPreviewGUI(Rect r, GUIStyle background)
        {
            if (Event.current.type == EventType.Repaint)
            {
                background.Draw(r, false, false, false, false);
            }

            // show texture
            Texture t = target as Texture;

            if (t == null) // texture might be gone by now, in case this code is used for floating texture preview
            {
                return;
            }

            // Render target must be created before we can display it (case 491797)
            RenderTexture rt = t as RenderTexture;

            if (rt != null)
            {
                if (!SystemInfo.IsFormatSupported(rt.graphicsFormat, FormatUsage.Render))
                {
                    return; // can't do this RT format
                }
                rt.Create();
            }

            if (IsCubemap())
            {
                m_CubemapPreview.OnPreviewGUI(t, r, background);
                return;
            }

            // target can report zero sizes in some cases just after a parameter change;
            // guard against that.
            int texWidth  = Mathf.Max(t.width, 1);
            int texHeight = Mathf.Max(t.height, 1);

            float mipLevel   = GetMipLevelForRendering();
            float zoomLevel  = Mathf.Min(Mathf.Min(r.width / texWidth, r.height / texHeight), 1);
            Rect  wantedRect = new Rect(r.x, r.y, texWidth * zoomLevel, texHeight * zoomLevel);

            PreviewGUI.BeginScrollView(r, m_Pos, wantedRect, "PreHorizontalScrollbar", "PreHorizontalScrollbarThumb");
            FilterMode oldFilter = t.filterMode;

            TextureUtil.SetFilterModeNoDirty(t, FilterMode.Point);
            Texture2D      t2d            = t as Texture2D;
            ColorWriteMask colorWriteMask = ColorWriteMask.All;

            switch (m_PreviewMode)
            {
            case PreviewMode.R:
                colorWriteMask = ColorWriteMask.Red | ColorWriteMask.Alpha;
                break;

            case PreviewMode.G:
                colorWriteMask = ColorWriteMask.Green | ColorWriteMask.Alpha;
                break;

            case PreviewMode.B:
                colorWriteMask = ColorWriteMask.Blue | ColorWriteMask.Alpha;
                break;
            }

            if (m_PreviewMode == PreviewMode.A)
            {
                EditorGUI.DrawTextureAlpha(wantedRect, t, ScaleMode.StretchToFill, 0, mipLevel);
            }
            else
            {
                if (t2d != null && t2d.alphaIsTransparency)
                {
                    EditorGUI.DrawTextureTransparent(wantedRect, t, ScaleMode.StretchToFill, 0, mipLevel, colorWriteMask);
                }
                else
                {
                    EditorGUI.DrawPreviewTexture(wantedRect, t, null, ScaleMode.StretchToFill, 0, mipLevel, colorWriteMask);
                }
            }

            // TODO: Less hacky way to prevent sprite rects to not appear in smaller previews like icons.
            if ((wantedRect.width > 32 && wantedRect.height > 32) && Event.current.type == EventType.Repaint)
            {
                string           path            = AssetDatabase.GetAssetPath(t);
                TextureImporter  textureImporter = AssetImporter.GetAtPath(path) as TextureImporter;
                SpriteMetaData[] spritesheet     = textureImporter != null ? textureImporter.spritesheet : null;

                if (spritesheet != null && textureImporter.spriteImportMode == SpriteImportMode.Multiple)
                {
                    Rect screenRect = new Rect();
                    Rect sourceRect = new Rect();
                    GUI.CalculateScaledTextureRects(wantedRect, ScaleMode.StretchToFill, (float)t.width / (float)t.height, ref screenRect, ref sourceRect);

                    int origWidth  = t.width;
                    int origHeight = t.height;
                    textureImporter.GetWidthAndHeight(ref origWidth, ref origHeight);
                    float definitionScale = (float)t.width / (float)origWidth;

                    HandleUtility.ApplyWireMaterial();
                    GL.PushMatrix();
                    GL.MultMatrix(Handles.matrix);
                    GL.Begin(GL.LINES);
                    GL.Color(new Color(1f, 1f, 1f, 0.5f));
                    foreach (SpriteMetaData sprite in spritesheet)
                    {
                        Rect spriteRect       = sprite.rect;
                        Rect spriteScreenRect = new Rect();
                        spriteScreenRect.xMin = screenRect.xMin + screenRect.width * (spriteRect.xMin / t.width * definitionScale);
                        spriteScreenRect.xMax = screenRect.xMin + screenRect.width * (spriteRect.xMax / t.width * definitionScale);
                        spriteScreenRect.yMin = screenRect.yMin + screenRect.height * (1f - spriteRect.yMin / t.height * definitionScale);
                        spriteScreenRect.yMax = screenRect.yMin + screenRect.height * (1f - spriteRect.yMax / t.height * definitionScale);
                        DrawRect(spriteScreenRect);
                    }
                    GL.End();
                    GL.PopMatrix();
                }
            }

            TextureUtil.SetFilterModeNoDirty(t, oldFilter);

            m_Pos = PreviewGUI.EndScrollView();
            if (mipLevel != 0)
            {
                EditorGUI.DropShadowLabel(new Rect(r.x, r.y, r.width, 20), "Mip " + mipLevel);
            }
        }
Ejemplo n.º 17
0
        public override void OnPreviewGUI(Rect r, GUIStyle background)
        {
            if ((UnityEngine.Object)AudioClipInspector.s_DefaultIcon == (UnityEngine.Object)null)
            {
                AudioClipInspector.Init();
            }
            AudioClip target  = this.target as AudioClip;
            Event     current = Event.current;

            if (current.type != EventType.Repaint && current.type != EventType.Layout && current.type != EventType.Used)
            {
                int num = AudioUtil.GetSampleCount(target) / (int)r.width;
                switch (current.type)
                {
                case EventType.MouseDown:
                case EventType.MouseDrag:
                    if (!r.Contains(current.mousePosition) || AudioUtil.IsMovieAudio(target))
                    {
                        break;
                    }
                    if ((UnityEngine.Object) this.m_PlayingClip != (UnityEngine.Object)target)
                    {
                        AudioUtil.StopAllClips();
                        AudioUtil.PlayClip(target, 0, AudioClipInspector.m_bLoop);
                        this.m_PlayingClip = target;
                    }
                    AudioUtil.SetClipSamplePosition(target, num * (int)current.mousePosition.x);
                    current.Use();
                    break;
                }
            }
            else
            {
                if (Event.current.type == EventType.Repaint)
                {
                    background.Draw(r, false, false, false, false);
                }
                int channelCount = AudioUtil.GetChannelCount(target);
                AudioClipInspector.m_wantedRect = new Rect(r.x, r.y, r.width, r.height);
                float num = AudioClipInspector.m_wantedRect.width / target.length;
                if (!AudioUtil.HasPreview(target) && (AudioUtil.IsTrackerFile(target) ? 1 : (AudioUtil.IsMovieAudio(target) ? 1 : 0)) != 0)
                {
                    float y = (double)r.height <= 150.0 ? (float)((double)r.y + (double)r.height / 2.0 - 25.0) : (float)((double)r.y + (double)r.height / 2.0 - 10.0);
                    if ((double)r.width > 64.0)
                    {
                        if (AudioUtil.IsTrackerFile(target))
                        {
                            EditorGUI.DropShadowLabel(new Rect(r.x, y, r.width, 20f), string.Format("Module file with " + (object)AudioUtil.GetMusicChannelCount(target) + " channels."));
                        }
                        else if (AudioUtil.IsMovieAudio(target))
                        {
                            if ((double)r.width > 450.0)
                            {
                                EditorGUI.DropShadowLabel(new Rect(r.x, y, r.width, 20f), "Audio is attached to a movie. To audition the sound, play the movie.");
                            }
                            else
                            {
                                EditorGUI.DropShadowLabel(new Rect(r.x, y, r.width, 20f), "Audio is attached to a movie.");
                                EditorGUI.DropShadowLabel(new Rect(r.x, y + 10f, r.width, 20f), "To audition the sound, play the movie.");
                            }
                        }
                        else
                        {
                            EditorGUI.DropShadowLabel(new Rect(r.x, y, r.width, 20f), "Can not show PCM data for this file");
                        }
                    }
                    if ((UnityEngine.Object) this.m_PlayingClip == (UnityEngine.Object)target)
                    {
                        TimeSpan timeSpan = new TimeSpan(0, 0, 0, 0, (int)((double)AudioUtil.GetClipPosition(target) * 1000.0));
                        EditorGUI.DropShadowLabel(new Rect(AudioClipInspector.m_wantedRect.x, AudioClipInspector.m_wantedRect.y, AudioClipInspector.m_wantedRect.width, 20f), string.Format("Playing - {0:00}:{1:00}.{2:000}", (object)timeSpan.Minutes, (object)timeSpan.Seconds, (object)timeSpan.Milliseconds));
                    }
                }
                else
                {
                    PreviewGUI.BeginScrollView(AudioClipInspector.m_wantedRect, this.m_Position, AudioClipInspector.m_wantedRect, (GUIStyle)"PreHorizontalScrollbar", (GUIStyle)"PreHorizontalScrollbarThumb");
                    if (Event.current.type == EventType.Repaint)
                    {
                        this.DoRenderPreview(target, AudioUtil.GetImporterFromClip(target), AudioClipInspector.m_wantedRect, 1f);
                    }
                    for (int index = 0; index < channelCount; ++index)
                    {
                        if (channelCount > 1 && (double)r.width > 64.0)
                        {
                            EditorGUI.DropShadowLabel(new Rect(AudioClipInspector.m_wantedRect.x + 5f, AudioClipInspector.m_wantedRect.y + AudioClipInspector.m_wantedRect.height / (float)channelCount * (float)index, 30f, 20f), "ch " + (index + 1).ToString());
                        }
                    }
                    if ((UnityEngine.Object) this.m_PlayingClip == (UnityEngine.Object)target)
                    {
                        float    clipPosition = AudioUtil.GetClipPosition(target);
                        TimeSpan timeSpan     = new TimeSpan(0, 0, 0, 0, (int)((double)clipPosition * 1000.0));
                        GUI.DrawTexture(new Rect(AudioClipInspector.m_wantedRect.x + (float)(int)((double)num * (double)clipPosition), AudioClipInspector.m_wantedRect.y, 2f, AudioClipInspector.m_wantedRect.height), (Texture)EditorGUIUtility.whiteTexture);
                        if ((double)r.width > 64.0)
                        {
                            EditorGUI.DropShadowLabel(new Rect(AudioClipInspector.m_wantedRect.x, AudioClipInspector.m_wantedRect.y, AudioClipInspector.m_wantedRect.width, 20f), string.Format("{0:00}:{1:00}.{2:000}", (object)timeSpan.Minutes, (object)timeSpan.Seconds, (object)timeSpan.Milliseconds));
                        }
                        else
                        {
                            EditorGUI.DropShadowLabel(new Rect(AudioClipInspector.m_wantedRect.x, AudioClipInspector.m_wantedRect.y, AudioClipInspector.m_wantedRect.width, 20f), string.Format("{0:00}:{1:00}", (object)timeSpan.Minutes, (object)timeSpan.Seconds));
                        }
                        if (!AudioUtil.IsClipPlaying(target))
                        {
                            this.m_PlayingClip = (AudioClip)null;
                        }
                    }
                    PreviewGUI.EndScrollView();
                }
                if (AudioClipInspector.m_bPlayFirst)
                {
                    AudioUtil.PlayClip(target, 0, AudioClipInspector.m_bLoop);
                    this.m_PlayingClip = target;
                    AudioClipInspector.m_bPlayFirst = false;
                }
                if (!this.playing)
                {
                    return;
                }
                GUIView.current.Repaint();
            }
        }
Ejemplo n.º 18
0
        public override void OnPreviewGUI(Rect r, GUIStyle background)
        {
            if (s_DefaultIcon == null)
            {
                Init();
            }
            AudioClip target  = this.target as AudioClip;
            Event     current = Event.current;

            if (((current.type == EventType.Repaint) || (current.type == EventType.Layout)) || (current.type == EventType.Used))
            {
                if (Event.current.type == EventType.Repaint)
                {
                    background.Draw(r, false, false, false, false);
                }
                int channelCount = AudioUtil.GetChannelCount(target);
                m_wantedRect = new Rect(r.x, r.y, r.width, r.height);
                float num3 = m_wantedRect.width / target.length;
                if (!AudioUtil.HasPreview(target) && (AudioUtil.IsTrackerFile(target) || AudioUtil.IsMovieAudio(target)))
                {
                    float y = (r.height <= 150f) ? ((r.y + (r.height / 2f)) - 25f) : ((r.y + (r.height / 2f)) - 10f);
                    if (r.width > 64f)
                    {
                        if (AudioUtil.IsTrackerFile(target))
                        {
                            EditorGUI.DropShadowLabel(new Rect(r.x, y, r.width, 20f), string.Format("Module file with " + AudioUtil.GetMusicChannelCount(target) + " channels.", new object[0]));
                        }
                        else if (AudioUtil.IsMovieAudio(target))
                        {
                            if (r.width > 450f)
                            {
                                EditorGUI.DropShadowLabel(new Rect(r.x, y, r.width, 20f), "Audio is attached to a movie. To audition the sound, play the movie.");
                            }
                            else
                            {
                                EditorGUI.DropShadowLabel(new Rect(r.x, y, r.width, 20f), "Audio is attached to a movie.");
                                EditorGUI.DropShadowLabel(new Rect(r.x, y + 10f, r.width, 20f), "To audition the sound, play the movie.");
                            }
                        }
                        else
                        {
                            EditorGUI.DropShadowLabel(new Rect(r.x, y, r.width, 20f), "Can not show PCM data for this file");
                        }
                    }
                    if (this.m_PlayingClip == target)
                    {
                        float    clipPosition = AudioUtil.GetClipPosition(target);
                        TimeSpan span         = new TimeSpan(0, 0, 0, 0, (int)(clipPosition * 1000f));
                        EditorGUI.DropShadowLabel(new Rect(m_wantedRect.x, m_wantedRect.y, m_wantedRect.width, 20f), string.Format("Playing - {0:00}:{1:00}.{2:000}", span.Minutes, span.Seconds, span.Milliseconds));
                    }
                }
                else
                {
                    PreviewGUI.BeginScrollView(m_wantedRect, this.m_Position, m_wantedRect, "PreHorizontalScrollbar", "PreHorizontalScrollbarThumb");
                    Texture2D image = null;
                    if (r.width < 100f)
                    {
                        image = AssetPreview.GetAssetPreview(target);
                    }
                    else
                    {
                        image = AudioUtil.GetWaveFormFast(target, 1, 0, target.samples, r.width, r.height);
                    }
                    if (image == null)
                    {
                        Rect position = new Rect {
                            x      = ((m_wantedRect.width - s_DefaultIcon.width) / 2f) + m_wantedRect.x,
                            y      = ((m_wantedRect.height - s_DefaultIcon.height) / 2f) + m_wantedRect.y,
                            width  = s_DefaultIcon.width,
                            height = s_DefaultIcon.height
                        };
                        GUI.DrawTexture(position, s_DefaultIcon);
                        base.Repaint();
                    }
                    else
                    {
                        GUI.DrawTexture(new Rect(m_wantedRect.x, m_wantedRect.y, m_wantedRect.width, m_wantedRect.height), image);
                    }
                    for (int i = 0; i < channelCount; i++)
                    {
                        if ((channelCount > 1) && (r.width > 64f))
                        {
                            Rect rect2 = new Rect(m_wantedRect.x + 5f, m_wantedRect.y + ((m_wantedRect.height / ((float)channelCount)) * i), 30f, 20f);
                            EditorGUI.DropShadowLabel(rect2, "ch " + ((i + 1)).ToString());
                        }
                    }
                    if (this.m_PlayingClip == target)
                    {
                        float    num7  = AudioUtil.GetClipPosition(target);
                        TimeSpan span2 = new TimeSpan(0, 0, 0, 0, (int)(num7 * 1000f));
                        GUI.DrawTexture(new Rect(m_wantedRect.x + ((int)(num3 * num7)), m_wantedRect.y, 2f, m_wantedRect.height), EditorGUIUtility.whiteTexture);
                        if (r.width > 64f)
                        {
                            EditorGUI.DropShadowLabel(new Rect(m_wantedRect.x, m_wantedRect.y, m_wantedRect.width, 20f), string.Format("{0:00}:{1:00}.{2:000}", span2.Minutes, span2.Seconds, span2.Milliseconds));
                        }
                        else
                        {
                            EditorGUI.DropShadowLabel(new Rect(m_wantedRect.x, m_wantedRect.y, m_wantedRect.width, 20f), string.Format("{0:00}:{1:00}", span2.Minutes, span2.Seconds));
                        }
                        if (!AudioUtil.IsClipPlaying(target))
                        {
                            this.m_PlayingClip = null;
                        }
                    }
                    PreviewGUI.EndScrollView();
                }
                if (m_bPlayFirst)
                {
                    AudioUtil.PlayClip(target, 0, m_bLoop);
                    this.m_PlayingClip = target;
                    m_bPlayFirst       = false;
                }
                if (this.playing)
                {
                    GUIView.current.Repaint();
                }
            }
            else
            {
                int num = AudioUtil.GetSampleCount(target) / ((int)r.width);
                switch (current.type)
                {
                case EventType.MouseDown:
                case EventType.MouseDrag:
                    if (r.Contains(current.mousePosition) && !AudioUtil.IsMovieAudio(target))
                    {
                        if (this.m_PlayingClip != target)
                        {
                            AudioUtil.StopAllClips();
                            AudioUtil.PlayClip(target, 0, m_bLoop);
                            this.m_PlayingClip = target;
                        }
                        AudioUtil.SetClipSamplePosition(target, num * ((int)current.mousePosition.x));
                        current.Use();
                    }
                    break;
                }
            }
        }
Ejemplo n.º 19
0
        public override void OnPreviewGUI(Rect r, GUIStyle background)
        {
            if (AudioClipInspector.s_DefaultIcon == null)
            {
                AudioClipInspector.Init();
            }
            AudioClip audioClip = base.target as AudioClip;
            Event     current   = Event.current;

            if (current.type != EventType.Repaint && current.type != EventType.Layout && current.type != EventType.Used)
            {
                int       num  = AudioUtil.GetSampleCount(audioClip) / (int)r.width;
                EventType type = current.type;
                if (type == EventType.MouseDrag || type == EventType.MouseDown)
                {
                    if (r.Contains(current.mousePosition) && !AudioUtil.IsMovieAudio(audioClip))
                    {
                        if (this.m_PlayingClip != audioClip)
                        {
                            AudioUtil.StopAllClips();
                            AudioUtil.PlayClip(audioClip, 0, AudioClipInspector.m_bLoop);
                            this.m_PlayingClip = audioClip;
                        }
                        AudioUtil.SetClipSamplePosition(audioClip, num * (int)current.mousePosition.x);
                        current.Use();
                    }
                }
            }
            else
            {
                if (Event.current.type == EventType.Repaint)
                {
                    background.Draw(r, false, false, false, false);
                }
                int channelCount = AudioUtil.GetChannelCount(audioClip);
                AudioClipInspector.m_wantedRect = new Rect(r.x, r.y, r.width, r.height);
                float num2 = AudioClipInspector.m_wantedRect.width / audioClip.length;
                if (!AudioUtil.HasPreview(audioClip) && (AudioUtil.IsTrackerFile(audioClip) || AudioUtil.IsMovieAudio(audioClip)))
                {
                    float num3 = (r.height <= 150f) ? (r.y + r.height / 2f - 25f) : (r.y + r.height / 2f - 10f);
                    if (r.width > 64f)
                    {
                        if (AudioUtil.IsTrackerFile(audioClip))
                        {
                            EditorGUI.DropShadowLabel(new Rect(r.x, num3, r.width, 20f), string.Format("Module file with " + AudioUtil.GetMusicChannelCount(audioClip) + " channels.", new object[0]));
                        }
                        else if (AudioUtil.IsMovieAudio(audioClip))
                        {
                            if (r.width > 450f)
                            {
                                EditorGUI.DropShadowLabel(new Rect(r.x, num3, r.width, 20f), "Audio is attached to a movie. To audition the sound, play the movie.");
                            }
                            else
                            {
                                EditorGUI.DropShadowLabel(new Rect(r.x, num3, r.width, 20f), "Audio is attached to a movie.");
                                EditorGUI.DropShadowLabel(new Rect(r.x, num3 + 10f, r.width, 20f), "To audition the sound, play the movie.");
                            }
                        }
                        else
                        {
                            EditorGUI.DropShadowLabel(new Rect(r.x, num3, r.width, 20f), "Can not show PCM data for this file");
                        }
                    }
                    if (this.m_PlayingClip == audioClip)
                    {
                        float    clipPosition = AudioUtil.GetClipPosition(audioClip);
                        TimeSpan timeSpan     = new TimeSpan(0, 0, 0, 0, (int)(clipPosition * 1000f));
                        EditorGUI.DropShadowLabel(new Rect(AudioClipInspector.m_wantedRect.x, AudioClipInspector.m_wantedRect.y, AudioClipInspector.m_wantedRect.width, 20f), string.Format("Playing - {0:00}:{1:00}.{2:000}", timeSpan.Minutes, timeSpan.Seconds, timeSpan.Milliseconds));
                    }
                }
                else
                {
                    PreviewGUI.BeginScrollView(AudioClipInspector.m_wantedRect, this.m_Position, AudioClipInspector.m_wantedRect, "PreHorizontalScrollbar", "PreHorizontalScrollbarThumb");
                    if (Event.current.type == EventType.Repaint)
                    {
                        this.DoRenderPreview(audioClip, AudioUtil.GetImporterFromClip(audioClip), AudioClipInspector.m_wantedRect, 1f);
                    }
                    for (int i = 0; i < channelCount; i++)
                    {
                        if (channelCount > 1 && r.width > 64f)
                        {
                            Rect position = new Rect(AudioClipInspector.m_wantedRect.x + 5f, AudioClipInspector.m_wantedRect.y + AudioClipInspector.m_wantedRect.height / (float)channelCount * (float)i, 30f, 20f);
                            EditorGUI.DropShadowLabel(position, "ch " + (i + 1).ToString());
                        }
                    }
                    if (this.m_PlayingClip == audioClip)
                    {
                        float    clipPosition2 = AudioUtil.GetClipPosition(audioClip);
                        TimeSpan timeSpan2     = new TimeSpan(0, 0, 0, 0, (int)(clipPosition2 * 1000f));
                        GUI.DrawTexture(new Rect(AudioClipInspector.m_wantedRect.x + (float)((int)(num2 * clipPosition2)), AudioClipInspector.m_wantedRect.y, 2f, AudioClipInspector.m_wantedRect.height), EditorGUIUtility.whiteTexture);
                        if (r.width > 64f)
                        {
                            EditorGUI.DropShadowLabel(new Rect(AudioClipInspector.m_wantedRect.x, AudioClipInspector.m_wantedRect.y, AudioClipInspector.m_wantedRect.width, 20f), string.Format("{0:00}:{1:00}.{2:000}", timeSpan2.Minutes, timeSpan2.Seconds, timeSpan2.Milliseconds));
                        }
                        else
                        {
                            EditorGUI.DropShadowLabel(new Rect(AudioClipInspector.m_wantedRect.x, AudioClipInspector.m_wantedRect.y, AudioClipInspector.m_wantedRect.width, 20f), string.Format("{0:00}:{1:00}", timeSpan2.Minutes, timeSpan2.Seconds));
                        }
                        if (!AudioUtil.IsClipPlaying(audioClip))
                        {
                            this.m_PlayingClip = null;
                        }
                    }
                    PreviewGUI.EndScrollView();
                }
                if (AudioClipInspector.m_bPlayFirst)
                {
                    AudioUtil.PlayClip(audioClip, 0, AudioClipInspector.m_bLoop);
                    this.m_PlayingClip = audioClip;
                    AudioClipInspector.m_bPlayFirst = false;
                }
                if (this.playing)
                {
                    GUIView.current.Repaint();
                }
            }
        }
Ejemplo n.º 20
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();
            }
        }
Ejemplo n.º 21
0
        public override void OnPreviewGUI(Rect r, GUIStyle background)
        {
            if (Event.current.type == EventType.Repaint)
            {
                background.Draw(r, false, false, false, false);
            }
            Texture       target        = this.target as Texture;
            RenderTexture renderTexture = target as RenderTexture;

            if ((UnityEngine.Object)renderTexture != (UnityEngine.Object)null)
            {
                if (!SystemInfo.SupportsRenderTextureFormat(renderTexture.format))
                {
                    return;
                }
                renderTexture.Create();
            }
            if (this.IsCubemap())
            {
                this.m_CubemapPreview.OnPreviewGUI(target, r, background);
            }
            else
            {
                int   num1 = Mathf.Max(target.width, 1);
                int   num2 = Mathf.Max(target.height, 1);
                float levelForRendering = this.GetMipLevelForRendering();
                float num3  = Mathf.Min(Mathf.Min(r.width / (float)num1, r.height / (float)num2), 1f);
                Rect  rect1 = new Rect(r.x, r.y, (float)num1 * num3, (float)num2 * num3);
                PreviewGUI.BeginScrollView(r, this.m_Pos, rect1, (GUIStyle)"PreHorizontalScrollbar", (GUIStyle)"PreHorizontalScrollbarThumb");
                float mipMapBias = target.mipMapBias;
                TextureUtil.SetMipMapBiasNoDirty(target, levelForRendering - this.Log2((float)num1 / rect1.width));
                UnityEngine.FilterMode filterMode = target.filterMode;
                TextureUtil.SetFilterModeNoDirty(target, UnityEngine.FilterMode.Point);
                if (this.m_ShowAlpha)
                {
                    EditorGUI.DrawTextureAlpha(rect1, target);
                }
                else
                {
                    Texture2D texture2D = target as Texture2D;
                    if ((UnityEngine.Object)texture2D != (UnityEngine.Object)null && texture2D.alphaIsTransparency)
                    {
                        EditorGUI.DrawTextureTransparent(rect1, target);
                    }
                    else
                    {
                        EditorGUI.DrawPreviewTexture(rect1, target);
                    }
                }
                if ((double)rect1.width > 32.0 && (double)rect1.height > 32.0)
                {
                    TextureImporter  atPath = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath((UnityEngine.Object)target)) as TextureImporter;
                    SpriteMetaData[] spriteMetaDataArray = !((UnityEngine.Object)atPath != (UnityEngine.Object)null) ? (SpriteMetaData[])null : atPath.spritesheet;
                    if (spriteMetaDataArray != null && atPath.spriteImportMode == SpriteImportMode.Multiple)
                    {
                        Rect outScreenRect = new Rect();
                        Rect outSourceRect = new Rect();
                        GUI.CalculateScaledTextureRects(rect1, ScaleMode.StretchToFill, (float)target.width / (float)target.height, ref outScreenRect, ref outSourceRect);
                        int width  = target.width;
                        int height = target.height;
                        atPath.GetWidthAndHeight(ref width, ref height);
                        float num4 = (float)target.width / (float)width;
                        HandleUtility.ApplyWireMaterial();
                        GL.PushMatrix();
                        GL.MultMatrix(Handles.matrix);
                        GL.Begin(1);
                        GL.Color(new Color(1f, 1f, 1f, 0.5f));
                        foreach (SpriteMetaData spriteMetaData in spriteMetaDataArray)
                        {
                            Rect rect2 = spriteMetaData.rect;
                            this.DrawRect(new Rect()
                            {
                                xMin = outScreenRect.xMin + outScreenRect.width * (rect2.xMin / (float)target.width * num4),
                                xMax = outScreenRect.xMin + outScreenRect.width * (rect2.xMax / (float)target.width * num4),
                                yMin = outScreenRect.yMin + outScreenRect.height * (float)(1.0 - (double)rect2.yMin / (double)target.height * (double)num4),
                                yMax = outScreenRect.yMin + outScreenRect.height * (float)(1.0 - (double)rect2.yMax / (double)target.height * (double)num4)
                            });
                        }
                        GL.End();
                        GL.PopMatrix();
                    }
                }
                TextureUtil.SetMipMapBiasNoDirty(target, mipMapBias);
                TextureUtil.SetFilterModeNoDirty(target, filterMode);
                this.m_Pos = PreviewGUI.EndScrollView();
                if ((double)levelForRendering == 0.0)
                {
                    return;
                }
                EditorGUI.DropShadowLabel(new Rect(r.x, r.y, r.width, 20f), "Mip " + (object)levelForRendering);
            }
        }
        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();
            }
        }
Ejemplo n.º 23
0
        public override void OnPreviewGUI(Rect r, GUIStyle background)
        {
            if (s_DefaultIcon == null)
            {
                Init();
            }

            AudioClip clip = target as AudioClip;

            Event evt = Event.current;

            if (evt.type != EventType.Repaint && evt.type != EventType.Layout && evt.type != EventType.Used)
            {
                int px2sample = (AudioUtil.GetSampleCount(clip) / (int)r.width);

                switch (evt.type)
                {
                case EventType.MouseDrag:
                case EventType.MouseDown:
                {
                    if (r.Contains(evt.mousePosition) && !AudioUtil.IsMovieAudio(clip))
                    {
                        if (m_PlayingClip != clip || !AudioUtil.IsClipPlaying(clip))
                        {
                            AudioUtil.StopAllClips();
                            AudioUtil.PlayClip(clip, 0, m_bLoop);
                            m_PlayingClip      = clip;
                            m_PlayingInspector = this;
                        }
                        AudioUtil.SetClipSamplePosition(clip, px2sample * (int)evt.mousePosition.x);
                        evt.Use();
                    }
                }
                break;
                }
                return;
            }

            if (Event.current.type == EventType.Repaint)
            {
                background.Draw(r, false, false, false, false);
            }

            int c = AudioUtil.GetChannelCount(clip);

            m_wantedRect = new Rect(r.x, r.y, r.width, r.height);
            float sec2px = ((float)m_wantedRect.width / clip.length);

            bool previewAble = AudioUtil.HasPreview(clip) || !(AudioUtil.IsTrackerFile(clip) || AudioUtil.IsMovieAudio(clip));

            if (!previewAble)
            {
                float labelY = (r.height > 150) ? r.y + (r.height / 2) - 10 :  r.y + (r.height / 2) - 25;
                if (r.width > 64)
                {
                    if (AudioUtil.IsTrackerFile(clip))
                    {
                        EditorGUI.DropShadowLabel(new Rect(r.x, labelY, r.width, 20), string.Format("Module file with " + AudioUtil.GetMusicChannelCount(clip) + " channels."));
                    }
                    else if (AudioUtil.IsMovieAudio(clip))
                    {
                        if (r.width > 450)
                        {
                            EditorGUI.DropShadowLabel(new Rect(r.x, labelY, r.width, 20), "Audio is attached to a movie. To audition the sound, play the movie.");
                        }
                        else
                        {
                            EditorGUI.DropShadowLabel(new Rect(r.x, labelY, r.width, 20), "Audio is attached to a movie.");
                            EditorGUI.DropShadowLabel(new Rect(r.x, labelY + 10, r.width, 20), "To audition the sound, play the movie.");
                        }
                    }
                    else
                    {
                        EditorGUI.DropShadowLabel(new Rect(r.x, labelY, r.width, 20), "Can not show PCM data for this file");
                    }
                }

                if (m_PlayingInspector == this && m_PlayingClip == clip)
                {
                    float t = AudioUtil.GetClipPosition(clip);

                    System.TimeSpan ts = new System.TimeSpan(0, 0, 0, 0, (int)(t * 1000.0f));

                    EditorGUI.DropShadowLabel(new Rect(m_wantedRect.x, m_wantedRect.y, m_wantedRect.width, 20), string.Format("Playing - {0:00}:{1:00}.{2:000}", ts.Minutes, ts.Seconds, ts.Milliseconds));
                }
            }
            else
            {
                PreviewGUI.BeginScrollView(m_wantedRect, m_Position, m_wantedRect, "PreHorizontalScrollbar", "PreHorizontalScrollbarThumb");

                if (Event.current.type == EventType.Repaint)
                {
                    DoRenderPreview(clip, AudioUtil.GetImporterFromClip(clip), m_wantedRect, 1.0f);
                }

                for (int i = 0; i < c; ++i)
                {
                    if (c > 1 && r.width > 64)
                    {
                        var labelRect = new Rect(m_wantedRect.x + 5, m_wantedRect.y + (m_wantedRect.height / c) * i, 30, 20);
                        EditorGUI.DropShadowLabel(labelRect, "ch " + (i + 1).ToString());
                    }
                }

                if (m_PlayingInspector == this && m_PlayingClip == clip)
                {
                    float t = AudioUtil.GetClipPosition(clip);

                    System.TimeSpan ts = new System.TimeSpan(0, 0, 0, 0, (int)(t * 1000.0f));

                    GUI.DrawTexture(new Rect(m_wantedRect.x + (int)(sec2px * t), m_wantedRect.y, 2, m_wantedRect.height), EditorGUIUtility.whiteTexture);
                    if (r.width > 64)
                    {
                        EditorGUI.DropShadowLabel(new Rect(m_wantedRect.x, m_wantedRect.y, m_wantedRect.width, 20), string.Format("{0:00}:{1:00}.{2:000}", ts.Minutes, ts.Seconds, ts.Milliseconds));
                    }
                    else
                    {
                        EditorGUI.DropShadowLabel(new Rect(m_wantedRect.x, m_wantedRect.y, m_wantedRect.width, 20), string.Format("{0:00}:{1:00}", ts.Minutes, ts.Seconds));
                    }
                }


                PreviewGUI.EndScrollView();
            }


            // autoplay start?
            if (m_bAutoPlay && m_PlayingClip != clip && m_PlayingInspector == this)
            {
                AudioUtil.StopAllClips();
                AudioUtil.PlayClip(clip, 0, m_bLoop);
                m_PlayingClip      = clip;
                m_PlayingInspector = this;
            }

            // force update GUI
            if (playing)
            {
                GUIView.current.Repaint();
            }
        }
Ejemplo n.º 24
0
        public override void OnPreviewGUI(Rect r, GUIStyle background)
        {
            if (s_DefaultIcon == null)
            {
                Init();
            }

            AudioClip clip = target as AudioClip;

            Event evt = Event.current;

            if (evt.type != EventType.Repaint && evt.type != EventType.Layout && evt.type != EventType.Used)
            {
                switch (evt.type)
                {
                case EventType.MouseDrag:
                case EventType.MouseDown:
                {
                    if (r.Contains(evt.mousePosition))
                    {
                        var startSample = (int)(evt.mousePosition.x * (AudioUtil.GetSampleCount(clip) / (int)r.width));
                        if (!AudioUtil.IsClipPlaying(clip) || clip != m_Clip)
                        {
                            PlayClip(clip, startSample, s_Loop);
                        }
                        else
                        {
                            AudioUtil.SetClipSamplePosition(clip, startSample);
                        }
                        evt.Use();
                    }
                }
                break;
                }
                return;
            }

            if (Event.current.type == EventType.Repaint)
            {
                background.Draw(r, false, false, false, false);
            }

            int c = AudioUtil.GetChannelCount(clip);

            s_WantedRect = new Rect(r.x, r.y, r.width, r.height);
            float sec2px = ((float)s_WantedRect.width / clip.length);

            bool previewAble = AudioUtil.HasPreview(clip) || !(AudioUtil.IsTrackerFile(clip));

            if (!previewAble)
            {
                float labelY = (r.height > 150) ? r.y + (r.height / 2) - 10 :  r.y + (r.height / 2) - 25;
                if (r.width > 64)
                {
                    if (AudioUtil.IsTrackerFile(clip))
                    {
                        EditorGUI.DropShadowLabel(new Rect(r.x, labelY, r.width, 20), string.Format("Module file with " + AudioUtil.GetMusicChannelCount(clip) + " channels."));
                    }
                    else
                    {
                        EditorGUI.DropShadowLabel(new Rect(r.x, labelY, r.width, 20), "Can not show PCM data for this file");
                    }
                }

                if (m_Clip == clip)
                {
                    float t = AudioUtil.GetClipPosition(clip);

                    System.TimeSpan ts = new System.TimeSpan(0, 0, 0, 0, (int)(t * 1000.0f));

                    EditorGUI.DropShadowLabel(new Rect(s_WantedRect.x, s_WantedRect.y, s_WantedRect.width, 20), string.Format("Playing - {0:00}:{1:00}.{2:000}", ts.Minutes, ts.Seconds, ts.Milliseconds));
                }
            }
            else
            {
                PreviewGUI.BeginScrollView(s_WantedRect, m_Position, s_WantedRect, "PreHorizontalScrollbar", "PreHorizontalScrollbarThumb");

                if (Event.current.type == EventType.Repaint)
                {
                    DoRenderPreview(true, clip, AudioUtil.GetImporterFromClip(clip), s_WantedRect, 1.0f);
                }

                for (int i = 0; i < c; ++i)
                {
                    if (c > 1 && r.width > 64)
                    {
                        var labelRect = new Rect(s_WantedRect.x + 5, s_WantedRect.y + (s_WantedRect.height / c) * i, 30, 20);
                        EditorGUI.DropShadowLabel(labelRect, "ch " + (i + 1).ToString());
                    }
                }

                if (m_Clip == clip)
                {
                    float t = AudioUtil.GetClipPosition(clip);

                    System.TimeSpan ts = new System.TimeSpan(0, 0, 0, 0, (int)(t * 1000.0f));

                    GUI.DrawTexture(new Rect(s_WantedRect.x + (int)(sec2px * t), s_WantedRect.y, 2, s_WantedRect.height), EditorGUIUtility.whiteTexture);
                    if (r.width > 64)
                    {
                        EditorGUI.DropShadowLabel(new Rect(s_WantedRect.x, s_WantedRect.y, s_WantedRect.width, 20), string.Format("{0:00}:{1:00}.{2:000}", ts.Minutes, ts.Seconds, ts.Milliseconds));
                    }
                    else
                    {
                        EditorGUI.DropShadowLabel(new Rect(s_WantedRect.x, s_WantedRect.y, s_WantedRect.width, 20), string.Format("{0:00}:{1:00}", ts.Minutes, ts.Seconds));
                    }
                }

                PreviewGUI.EndScrollView();
            }


            if (!m_MultiEditing && (s_PlayFirst || (s_AutoPlay && m_Clip != clip)))
            {
                // Autoplay preview
                PlayClip(clip, 0, s_Loop);
                s_PlayFirst = false;
            }

            // force update GUI
            if (playing)
            {
                GUIView.current.Repaint();
            }
        }