Beispiel #1
0
 void InitializeZoomArea()
 {
     m_ZoomArea = new ZoomableArea(true, false)
     {
         uniformScale = true, upDirection = ZoomableArea.YDirection.Negative
     };
 }
 public void DoGUI(int frameIndex, float width, float ypos, float height)
 {
     Rect position = new Rect(0f, ypos - 1f, width, height + 1f);
     float num = 169f;
     if (Event.current.type == EventType.Repaint)
     {
         styles.profilerGraphBackground.Draw(position, false, false, false, false);
         EditorStyles.toolbar.Draw(new Rect(0f, (ypos + height) - 15f, num, 15f), false, false, false, false);
     }
     bool flag = false;
     if (this.m_TimeArea == null)
     {
         flag = true;
         this.m_TimeArea = new ZoomableArea();
         this.m_TimeArea.hRangeLocked = false;
         this.m_TimeArea.vRangeLocked = true;
         this.m_TimeArea.hSlider = true;
         this.m_TimeArea.vSlider = false;
         this.m_TimeArea.scaleWithWindow = true;
         this.m_TimeArea.rect = new Rect((position.x + num) - 1f, position.y, position.width - num, position.height);
         this.m_TimeArea.margin = 10f;
     }
     ProfilerFrameDataIterator iterator = new ProfilerFrameDataIterator();
     iterator.SetRoot(frameIndex, 0);
     this.m_TimeArea.hBaseRangeMin = 0f;
     this.m_TimeArea.hBaseRangeMax = iterator.frameTimeMS;
     if (flag)
     {
         this.PerformFrameSelected(iterator.frameTimeMS);
     }
     this.m_TimeArea.rect = new Rect(position.x + num, position.y, position.width - num, position.height);
     this.m_TimeArea.BeginViewGUI();
     this.m_TimeArea.EndViewGUI();
     position = this.m_TimeArea.drawRect;
     this.DrawBars(position, frameIndex);
     GUI.BeginClip(this.m_TimeArea.drawRect);
     position.x = 0f;
     position.y = 0f;
     int threadCount = 0;
     this.DoProfilerFrame(frameIndex, position, false, ref threadCount, 0f);
     bool enabled = GUI.enabled;
     GUI.enabled = false;
     int previousFrameIndex = ProfilerDriver.GetPreviousFrameIndex(frameIndex);
     if (previousFrameIndex != -1)
     {
         ProfilerFrameDataIterator iterator2 = new ProfilerFrameDataIterator();
         iterator2.SetRoot(previousFrameIndex, 0);
         this.DoProfilerFrame(previousFrameIndex, position, true, ref threadCount, -iterator2.frameTimeMS);
     }
     int nextFrameIndex = ProfilerDriver.GetNextFrameIndex(frameIndex);
     if (nextFrameIndex != -1)
     {
         ProfilerFrameDataIterator iterator3 = new ProfilerFrameDataIterator();
         iterator3.SetRoot(frameIndex, 0);
         this.DoProfilerFrame(nextFrameIndex, position, true, ref threadCount, iterator3.frameTimeMS);
     }
     GUI.enabled = enabled;
     GUI.EndClip();
 }
        private Rect ScaleRectByZoomableArea(Rect rect, ZoomableArea zoomableArea)
        {
            float num   = -(zoomableArea.shownArea.x / zoomableArea.shownArea.width) * rect.width;
            float num2  = ((zoomableArea.shownArea.y - (1f - zoomableArea.shownArea.height)) / zoomableArea.shownArea.height) * rect.height;
            float width = rect.width / zoomableArea.shownArea.width;

            return(new Rect(rect.x + num, rect.y + num2, width, rect.height / zoomableArea.shownArea.height));
        }
        private Rect ScaleRectByZoomableArea(Rect rect, ZoomableArea zoomableArea)
        {
            float num1   = (float)-((double)zoomableArea.shownArea.x / (double)zoomableArea.shownArea.width) * rect.width;
            float num2   = (zoomableArea.shownArea.y - (1f - zoomableArea.shownArea.height)) / zoomableArea.shownArea.height * rect.height;
            float width  = rect.width / zoomableArea.shownArea.width;
            float height = rect.height / zoomableArea.shownArea.height;

            return(new Rect(rect.x + num1, rect.y + num2, width, height));
        }
        private Rect ScaleRectByZoomableArea(Rect rect, ZoomableArea zoomableArea)
        {
            float x = -(zoomableArea.shownArea.x / zoomableArea.shownArea.width) * (rect.x + zoomableArea.rect.width);
            float y = ((zoomableArea.shownArea.y - (1f - zoomableArea.shownArea.height)) / zoomableArea.shownArea.height) * zoomableArea.rect.height;

            float width  = rect.width / zoomableArea.shownArea.width;
            float height = rect.height / zoomableArea.shownArea.height;

            return(new Rect(rect.x + x, rect.y + y, width, height));
        }
Beispiel #6
0
        private void ConfigureZoomArea()
        {
            this.m_ZoomArea.rect          = this.viewInWindow;
            this.m_ZoomArea.hBaseRangeMin = this.targetInContent.xMin;
            this.m_ZoomArea.vBaseRangeMin = this.targetInContent.yMin;
            this.m_ZoomArea.hBaseRangeMax = this.targetInContent.xMax;
            this.m_ZoomArea.vBaseRangeMax = this.targetInContent.yMax;
            ZoomableArea arg_93_0 = this.m_ZoomArea;
            float        num      = this.minScale;

            this.m_ZoomArea.vScaleMin = num;
            arg_93_0.hScaleMin        = num;
            ZoomableArea arg_B5_0 = this.m_ZoomArea;

            num = this.maxScale;
            this.m_ZoomArea.vScaleMax = num;
            arg_B5_0.hScaleMax        = num;
        }
        public void ObjectPreview(Rect r)
        {
            if (r.height > 0f)
            {
                if (s_Styles == null)
                {
                    s_Styles = new Styles();
                }
                List <Texture2D> list = new List <Texture2D>();
                foreach (GITextureType type in this.kObjectPreviewTextureTypes)
                {
                    list.Add(LightmapVisualizationUtility.GetGITexture(type));
                }
                if (list.Count != 0)
                {
                    Rect rect3;
                    Rect rect9;
                    if (this.m_ZoomablePreview == null)
                    {
                        this.m_ZoomablePreview           = new ZoomableArea(true);
                        this.m_ZoomablePreview.hRangeMin = 0f;
                        this.m_ZoomablePreview.vRangeMin = 0f;
                        this.m_ZoomablePreview.hRangeMax = 1f;
                        this.m_ZoomablePreview.vRangeMax = 1f;
                        this.m_ZoomablePreview.SetShownHRange(0f, 1f);
                        this.m_ZoomablePreview.SetShownVRange(0f, 1f);
                        this.m_ZoomablePreview.uniformScale    = true;
                        this.m_ZoomablePreview.scaleWithWindow = true;
                    }
                    GUI.Box(r, string.Empty, "PreBackground");
                    Rect position = new Rect(r);
                    position.y++;
                    position.height = 18f;
                    GUI.Box(position, string.Empty, EditorStyles.toolbar);
                    Rect rect2 = new Rect(r);
                    rect2.y++;
                    rect2.height = 18f;
                    rect2.width  = 120f;
                    rect3        = new Rect(r)
                    {
                        yMin  = rect3.yMin + rect2.height,
                        yMax  = rect3.yMax - 14f,
                        width = rect3.width - 11f
                    };
                    int index = Array.IndexOf <GUIContent>(kObjectPreviewTextureOptions, this.m_SelectedObjectPreviewTexture);
                    if (index < 0)
                    {
                        index = 0;
                    }
                    index = EditorGUI.Popup(rect2, index, kObjectPreviewTextureOptions, EditorStyles.toolbarPopup);
                    if (index >= kObjectPreviewTextureOptions.Length)
                    {
                        index = 0;
                    }
                    this.m_SelectedObjectPreviewTexture = kObjectPreviewTextureOptions[index];
                    LightmapType       lightmapType = ((this.kObjectPreviewTextureTypes[index] != GITextureType.Baked) && (this.kObjectPreviewTextureTypes[index] != GITextureType.BakedDirectional)) ? LightmapType.DynamicLightmap : LightmapType.StaticLightmap;
                    SerializedProperty property     = new SerializedObject(LightmapEditorSettings.GetLightmapSettings()).FindProperty("m_LightmapsMode");
                    bool flag = ((this.kObjectPreviewTextureTypes[index] == GITextureType.Baked) || (this.kObjectPreviewTextureTypes[index] == GITextureType.BakedDirectional)) && (property.intValue == 2);
                    if (flag)
                    {
                        GUIContent content = GUIContent.Temp("Indirect");
                        Rect       rect4   = rect2;
                        rect4.x    += rect2.width;
                        rect4.width = EditorStyles.toolbarButton.CalcSize(content).x;
                        this.m_HasSeparateIndirectUV = GUI.Toggle(rect4, this.m_HasSeparateIndirectUV, content.text, EditorStyles.toolbarButton);
                    }
                    switch (Event.current.type)
                    {
                    case EventType.ValidateCommand:
                    case EventType.ExecuteCommand:
                        if (Event.current.commandName == "FrameSelected")
                        {
                            Rect    rect5;
                            Vector4 lightmapTilingOffset = LightmapVisualizationUtility.GetLightmapTilingOffset(lightmapType);
                            Vector2 lhs     = new Vector2(lightmapTilingOffset.z, lightmapTilingOffset.w);
                            Vector2 vector3 = lhs + new Vector2(lightmapTilingOffset.x, lightmapTilingOffset.y);
                            lhs     = Vector2.Max(lhs, Vector2.zero);
                            vector3 = Vector2.Min(vector3, Vector2.one);
                            float num3 = 1f - lhs.y;
                            lhs.y     = 1f - vector3.y;
                            vector3.y = num3;
                            rect5     = new Rect(lhs.x, lhs.y, vector3.x - lhs.x, vector3.y - lhs.y)
                            {
                                x = rect5.x - (Mathf.Clamp(rect5.height - rect5.width, 0f, float.MaxValue) / 2f),
                                y = rect5.y - (Mathf.Clamp(rect5.width - rect5.height, 0f, float.MaxValue) / 2f)
                            };
                            float num5 = Mathf.Max(rect5.width, rect5.height);
                            rect5.height = num5;
                            rect5.width  = num5;
                            if (flag && this.m_HasSeparateIndirectUV)
                            {
                                rect5.x += 0.5f;
                            }
                            this.m_ZoomablePreview.shownArea = rect5;
                            Event.current.Use();
                        }
                        break;

                    case EventType.Repaint:
                    {
                        Texture2D texture = list[index];
                        if ((texture != null) && (Event.current.type == EventType.Repaint))
                        {
                            Rect rect7;
                            Rect rect8;
                            Rect rect = new Rect(0f, 0f, (float)texture.width, (float)texture.height);
                            rect  = this.ResizeRectToFit(rect, rect3);
                            rect  = this.CenterToRect(rect, rect3);
                            rect  = this.ScaleRectByZoomableArea(rect, this.m_ZoomablePreview);
                            rect7 = new Rect(rect)
                            {
                                x = rect7.x + 3f,
                                y = rect7.y + (rect3.y + 20f)
                            };
                            rect8 = new Rect(rect3)
                            {
                                y = rect8.y + (rect2.height + 3f)
                            };
                            float num4 = rect8.y - 14f;
                            rect7.y -= num4;
                            rect8.y -= num4;
                            UnityEngine.FilterMode filterMode = texture.filterMode;
                            texture.filterMode = UnityEngine.FilterMode.Point;
                            GITextureType textureType    = this.kObjectPreviewTextureTypes[index];
                            bool          drawSpecularUV = flag && this.m_HasSeparateIndirectUV;
                            LightmapVisualizationUtility.DrawTextureWithUVOverlay(texture, Selection.activeGameObject, rect8, rect7, textureType, drawSpecularUV);
                            texture.filterMode = filterMode;
                        }
                        break;
                    }
                    }
                    if (this.m_PreviousSelection != Selection.activeInstanceID)
                    {
                        this.m_PreviousSelection = Selection.activeInstanceID;
                        this.m_ZoomablePreview.SetShownHRange(0f, 1f);
                        this.m_ZoomablePreview.SetShownVRange(0f, 1f);
                    }
                    rect9 = new Rect(r)
                    {
                        yMin = rect9.yMin + rect2.height
                    };
                    this.m_ZoomablePreview.rect = rect9;
                    this.m_ZoomablePreview.BeginViewGUI();
                    this.m_ZoomablePreview.EndViewGUI();
                    GUILayoutUtility.GetRect(r.width, r.height);
                }
            }
        }
        private void DrawPreview(Rect r)
        {
            if (r.height <= 0)
            {
                return;
            }

            if (m_ZoomablePreview == null)
            {
                m_ZoomablePreview = new ZoomableArea(true);

                m_ZoomablePreview.hRangeMin = 0.0f;
                m_ZoomablePreview.vRangeMin = 0.0f;

                m_ZoomablePreview.hRangeMax = 1.0f;
                m_ZoomablePreview.vRangeMax = 1.0f;

                m_ZoomablePreview.SetShownHRange(0, 1);
                m_ZoomablePreview.SetShownVRange(0, 1);

                m_ZoomablePreview.uniformScale    = true;
                m_ZoomablePreview.scaleWithWindow = true;
            }

            m_ZoomablePreview.rect = r;

            m_ZoomablePreview.BeginViewGUI();

            m_ZoomablePreview.hSlider = m_ZoomablePreview.shownArea.width < 1;
            m_ZoomablePreview.vSlider = m_ZoomablePreview.shownArea.height < 1;

            Rect          drawableArea = m_ZoomablePreview.drawRect;
            GITextureType textureType  = GetSelectedTextureType();

            UpdateCachedTexture(textureType);

            if (m_CachedTexture.textureAvailability == GITextureAvailability.GITextureNotAvailable || m_CachedTexture.textureAvailability == GITextureAvailability.GITextureUnknown)
            {
                if (!isRealtimeLightmap)
                {
                    if (!LightmapVisualizationUtility.IsAtlasTextureType(textureType) && isIndexBased)
                    {
                        GUI.Label(drawableArea, Styles.TextureNotAvailableBakedAlbedoEmissive, Styles.PreviewLabel);
                    }
                    else if (textureType == GITextureType.BakedShadowMask)
                    {
                        GUI.Label(drawableArea, Styles.TextureNotAvailableBakedShadowmask, Styles.PreviewLabel);
                    }
                    else
                    {
                        GUI.Label(drawableArea, Styles.TextureNotAvailableBaked, Styles.PreviewLabel);
                    }
                }
                else
                {
                    GUI.Label(drawableArea, Styles.TextureNotAvailableRealtime, Styles.PreviewLabel);
                }

                return;
            }

            if (m_CachedTexture.textureAvailability == GITextureAvailability.GITextureLoading && m_CachedTexture.texture == null)
            {
                GUI.Label(drawableArea, Styles.TextureLoading, Styles.PreviewLabel);
                return;
            }

            LightmapType lightmapType = LightmapVisualizationUtility.GetLightmapType(textureType);

            switch (Event.current.type)
            {
            // 'F' will zoom to uv bounds
            case EventType.ValidateCommand:
            case EventType.ExecuteCommand:

                if (Event.current.commandName == EventCommandNames.FrameSelected && IsActiveGameObjectInLightmap(textureType))
                {
                    // There are instance based baked textures where we don't get any STs and can't do the framing
                    if (!isRealtimeLightmap && !LightmapVisualizationUtility.IsAtlasTextureType(textureType))
                    {
                        break;
                    }

                    Vector4 lightmapTilingOffset = LightmapVisualizationUtility.GetLightmapTilingOffset(lightmapType);

                    Vector2 min = new Vector2(lightmapTilingOffset.z, lightmapTilingOffset.w);
                    Vector2 max = min + new Vector2(lightmapTilingOffset.x, lightmapTilingOffset.y);

                    min = Vector2.Max(min, Vector2.zero);
                    max = Vector2.Min(max, Vector2.one);

                    Texture2D texture     = m_CachedTexture.texture;
                    Rect      textureRect = new Rect(r.x, r.y, texture.width, texture.height);
                    textureRect = ResizeRectToFit(textureRect, drawableArea);

                    float offsetX = 0.0f, offsetY = 0.0f;

                    if (textureRect.height == drawableArea.height)
                    {
                        offsetX = (drawableArea.width - textureRect.width) / drawableArea.width;
                    }
                    else
                    {
                        offsetY = (drawableArea.height - textureRect.height) / drawableArea.height;
                    }

                    // Make sure that the focus rectangle is a even square
                    Rect rect = new Rect(min.x, min.y, max.x - min.x, max.y - min.y);
                    rect.width = rect.height = Mathf.Max(rect.width, rect.height);
                    rect.x    -= (offsetX * min.x);
                    rect.y    += (offsetY * (1 - max.y));

                    m_ZoomablePreview.shownArea = rect;
                    Event.current.Use();
                }
                break;

            // Scale and draw texture and uv's
            case EventType.Repaint:
            {
                Texture2D texture = m_CachedTexture.texture;

                if (texture)
                {
                    Rect textureRect = new Rect(r.x, r.y, texture.width, texture.height);
                    textureRect = ResizeRectToFit(textureRect, drawableArea);
                    textureRect = ScaleRectByZoomableArea(textureRect, m_ZoomablePreview);

                    const int padding = 5;
                    textureRect.x      += padding;
                    textureRect.width  -= padding * 2;
                    textureRect.height -= padding;

                    // Texture shouldn't be filtered since it will make previewing really blurry
                    FilterMode prevMode = texture.filterMode;
                    texture.filterMode = FilterMode.Point;

                    LightmapVisualizationUtility.DrawTextureWithUVOverlay(texture,
                                                                          (m_ShowUVOverlay && IsActiveGameObjectInLightmap(textureType)) ? Selection.activeGameObject : null,
                                                                          m_ShowUVOverlay ? m_CachedTextureObjects : new GameObject[] {}, drawableArea, textureRect, textureType, exposure);
                    texture.filterMode = prevMode;
                }
            }
            break;
            }

            m_ZoomablePreview.EndViewGUI();
        }
 public void DoGUI(int frameIndex, float width, float ypos, float height)
 {
   Rect position = new Rect(0.0f, ypos - 1f, width, height + 1f);
   float width1 = 169f;
   if (Event.current.type == EventType.Repaint)
   {
     ProfilerTimelineGUI.styles.profilerGraphBackground.Draw(position, false, false, false, false);
     EditorStyles.toolbar.Draw(new Rect(0.0f, (float) ((double) ypos + (double) height - 15.0), width1, 15f), false, false, false, false);
   }
   bool flag = false;
   if (this.m_TimeArea == null)
   {
     flag = true;
     this.m_TimeArea = new ZoomableArea();
     this.m_TimeArea.hRangeLocked = false;
     this.m_TimeArea.vRangeLocked = true;
     this.m_TimeArea.hSlider = true;
     this.m_TimeArea.vSlider = false;
     this.m_TimeArea.scaleWithWindow = true;
     this.m_TimeArea.rect = new Rect((float) ((double) position.x + (double) width1 - 1.0), position.y, position.width - width1, position.height);
     this.m_TimeArea.margin = 10f;
   }
   ProfilerFrameDataIterator frameDataIterator1 = new ProfilerFrameDataIterator();
   frameDataIterator1.SetRoot(frameIndex, 0);
   this.m_TimeArea.hBaseRangeMin = 0.0f;
   this.m_TimeArea.hBaseRangeMax = frameDataIterator1.frameTimeMS;
   if (flag)
     this.PerformFrameSelected(frameDataIterator1.frameTimeMS);
   this.m_TimeArea.rect = new Rect(position.x + width1, position.y, position.width - width1, position.height);
   this.m_TimeArea.BeginViewGUI();
   this.m_TimeArea.EndViewGUI();
   Rect drawRect = this.m_TimeArea.drawRect;
   this.CalculateBars(drawRect, frameIndex, this.animationTime);
   this.DrawBars(drawRect, frameIndex);
   GUI.BeginClip(this.m_TimeArea.drawRect);
   drawRect.x = 0.0f;
   drawRect.y = 0.0f;
   int threadCount = 0;
   this.DoProfilerFrame(frameIndex, drawRect, false, ref threadCount, 0.0f);
   bool enabled = GUI.enabled;
   GUI.enabled = false;
   int previousFrameIndex = ProfilerDriver.GetPreviousFrameIndex(frameIndex);
   if (previousFrameIndex != -1)
   {
     ProfilerFrameDataIterator frameDataIterator2 = new ProfilerFrameDataIterator();
     frameDataIterator2.SetRoot(previousFrameIndex, 0);
     this.DoProfilerFrame(previousFrameIndex, drawRect, true, ref threadCount, -frameDataIterator2.frameTimeMS);
   }
   int nextFrameIndex = ProfilerDriver.GetNextFrameIndex(frameIndex);
   if (nextFrameIndex != -1)
   {
     ProfilerFrameDataIterator frameDataIterator2 = new ProfilerFrameDataIterator();
     frameDataIterator2.SetRoot(frameIndex, 0);
     this.DoProfilerFrame(nextFrameIndex, drawRect, true, ref threadCount, frameDataIterator2.frameTimeMS);
   }
   GUI.enabled = enabled;
   GUI.EndClip();
 }
 public void ObjectPreview(Rect r)
 {
     if (r.height > 0f)
     {
         if (this.m_ZoomablePreview == null)
         {
             this.m_ZoomablePreview           = new ZoomableArea(true);
             this.m_ZoomablePreview.hRangeMin = 0f;
             this.m_ZoomablePreview.vRangeMin = 0f;
             this.m_ZoomablePreview.hRangeMax = 1f;
             this.m_ZoomablePreview.vRangeMax = 1f;
             this.m_ZoomablePreview.SetShownHRange(0f, 1f);
             this.m_ZoomablePreview.SetShownVRange(0f, 1f);
             this.m_ZoomablePreview.uniformScale    = true;
             this.m_ZoomablePreview.scaleWithWindow = true;
         }
         GUI.Box(r, "", "PreBackground");
         Rect position = new Rect(r);
         position.y     += 1f;
         position.height = 18f;
         GUI.Box(position, "", EditorStyles.toolbar);
         Rect position2 = new Rect(r);
         position2.y     += 1f;
         position2.height = 18f;
         position2.width  = 120f;
         Rect rect = new Rect(r);
         rect.yMin  += position2.height;
         rect.yMax  -= 14f;
         rect.width -= 11f;
         int num = Array.IndexOf <GUIContent>(LightingWindowObjectTab.Styles.ObjectPreviewTextureOptions, this.m_SelectedObjectPreviewTexture);
         if (num < 0 || !LightmapVisualizationUtility.IsTextureTypeEnabled(this.kObjectPreviewTextureTypes[num]))
         {
             num = 0;
             this.m_SelectedObjectPreviewTexture = LightingWindowObjectTab.Styles.ObjectPreviewTextureOptions[num];
         }
         if (EditorGUI.DropdownButton(position2, this.m_SelectedObjectPreviewTexture, FocusType.Passive, EditorStyles.toolbarPopup))
         {
             GenericMenu genericMenu = new GenericMenu();
             for (int i = 0; i < LightingWindowObjectTab.Styles.ObjectPreviewTextureOptions.Length; i++)
             {
                 if (LightmapVisualizationUtility.IsTextureTypeEnabled(this.kObjectPreviewTextureTypes[i]))
                 {
                     genericMenu.AddItem(LightingWindowObjectTab.Styles.ObjectPreviewTextureOptions[i], num == i, new GenericMenu.MenuFunction2(this.SelectPreviewTextureOption), LightingWindowObjectTab.Styles.ObjectPreviewTextureOptions.ElementAt(i));
                 }
                 else
                 {
                     genericMenu.AddDisabledItem(LightingWindowObjectTab.Styles.ObjectPreviewTextureOptions.ElementAt(i));
                 }
             }
             genericMenu.DropDown(position2);
         }
         GITextureType gITextureType = this.kObjectPreviewTextureTypes[Array.IndexOf <GUIContent>(LightingWindowObjectTab.Styles.ObjectPreviewTextureOptions, this.m_SelectedObjectPreviewTexture)];
         if (this.m_CachedTexture.type != gITextureType || this.m_CachedTexture.contentHash != LightmapVisualizationUtility.GetSelectedObjectGITextureHash(gITextureType) || this.m_CachedTexture.contentHash == default(Hash128))
         {
             this.m_CachedTexture = LightmapVisualizationUtility.GetSelectedObjectGITexture(gITextureType);
         }
         if (this.m_CachedTexture.textureAvailability == GITextureAvailability.GITextureNotAvailable || this.m_CachedTexture.textureAvailability == GITextureAvailability.GITextureUnknown)
         {
             if (LightmapVisualizationUtility.IsBakedTextureType(gITextureType))
             {
                 if (gITextureType == GITextureType.BakedShadowMask)
                 {
                     GUI.Label(rect, LightingWindowObjectTab.Styles.TextureNotAvailableBakedShadowmask);
                 }
                 else
                 {
                     GUI.Label(rect, LightingWindowObjectTab.Styles.TextureNotAvailableBaked);
                 }
             }
             else
             {
                 GUI.Label(rect, LightingWindowObjectTab.Styles.TextureNotAvailableRealtime);
             }
         }
         else if (this.m_CachedTexture.textureAvailability == GITextureAvailability.GITextureLoading && this.m_CachedTexture.texture == null)
         {
             GUI.Label(rect, LightingWindowObjectTab.Styles.TextureLoading);
         }
         else
         {
             LightmapType lightmapType = LightmapVisualizationUtility.GetLightmapType(gITextureType);
             Event        current      = Event.current;
             EventType    type         = current.type;
             if (type != EventType.ValidateCommand && type != EventType.ExecuteCommand)
             {
                 if (type == EventType.Repaint)
                 {
                     Texture2D texture = this.m_CachedTexture.texture;
                     if (texture && Event.current.type == EventType.Repaint)
                     {
                         Rect rect2 = new Rect(0f, 0f, (float)texture.width, (float)texture.height);
                         rect2 = this.ResizeRectToFit(rect2, rect);
                         rect2 = this.CenterToRect(rect2, rect);
                         rect2 = this.ScaleRectByZoomableArea(rect2, this.m_ZoomablePreview);
                         Rect position3 = new Rect(rect2);
                         position3.x += 3f;
                         position3.y += rect.y + 20f;
                         Rect drawableArea = new Rect(rect);
                         drawableArea.y += position2.height + 3f;
                         float num2 = drawableArea.y - 14f;
                         position3.y    -= num2;
                         drawableArea.y -= num2;
                         FilterMode filterMode = texture.filterMode;
                         texture.filterMode = FilterMode.Point;
                         LightmapVisualizationUtility.DrawTextureWithUVOverlay(texture, Selection.activeGameObject, drawableArea, position3, gITextureType);
                         texture.filterMode = filterMode;
                     }
                 }
             }
             else if (Event.current.commandName == "FrameSelected")
             {
                 Vector4 lightmapTilingOffset = LightmapVisualizationUtility.GetLightmapTilingOffset(lightmapType);
                 Vector2 vector = new Vector2(lightmapTilingOffset.z, lightmapTilingOffset.w);
                 Vector2 lhs    = vector + new Vector2(lightmapTilingOffset.x, lightmapTilingOffset.y);
                 vector = Vector2.Max(vector, Vector2.zero);
                 lhs    = Vector2.Min(lhs, Vector2.one);
                 float y = 1f - vector.y;
                 vector.y = 1f - lhs.y;
                 lhs.y    = y;
                 Rect shownArea = new Rect(vector.x, vector.y, lhs.x - vector.x, lhs.y - vector.y);
                 shownArea.x -= Mathf.Clamp(shownArea.height - shownArea.width, 0f, 3.40282347E+38f) / 2f;
                 shownArea.y -= Mathf.Clamp(shownArea.width - shownArea.height, 0f, 3.40282347E+38f) / 2f;
                 float num3 = Mathf.Max(shownArea.width, shownArea.height);
                 shownArea.height = num3;
                 shownArea.width  = num3;
                 this.m_ZoomablePreview.shownArea = shownArea;
                 Event.current.Use();
             }
             if (this.m_PreviousSelection != Selection.activeInstanceID)
             {
                 this.m_PreviousSelection = Selection.activeInstanceID;
                 this.m_ZoomablePreview.SetShownHRange(0f, 1f);
                 this.m_ZoomablePreview.SetShownVRange(0f, 1f);
             }
             Rect rect3 = new Rect(r);
             rect3.yMin += position2.height;
             this.m_ZoomablePreview.rect = rect3;
             this.m_ZoomablePreview.BeginViewGUI();
             this.m_ZoomablePreview.EndViewGUI();
             GUILayoutUtility.GetRect(r.width, r.height);
         }
     }
 }
Beispiel #11
0
 private void InitializeZoomArea()
 {
     this.m_ZoomArea = new ZoomableArea(true, false);
     this.m_ZoomArea.uniformScale = true;
     this.m_ZoomArea.upDirection  = ZoomableArea.YDirection.Negative;
 }
        public void ObjectPreview(Rect r)
        {
            if ((double)r.height <= 0.0)
            {
                return;
            }
            if (LightingWindowObjectTab.s_Styles == null)
            {
                LightingWindowObjectTab.s_Styles = new LightingWindowObjectTab.Styles();
            }
            List <Texture2D> texture2DList = new List <Texture2D>();

            foreach (GITextureType previewTextureType in this.kObjectPreviewTextureTypes)
            {
                texture2DList.Add(LightmapVisualizationUtility.GetGITexture(previewTextureType));
            }
            if (texture2DList.Count == 0)
            {
                return;
            }
            if (this.m_ZoomablePreview == null)
            {
                this.m_ZoomablePreview           = new ZoomableArea(true);
                this.m_ZoomablePreview.hRangeMin = 0.0f;
                this.m_ZoomablePreview.vRangeMin = 0.0f;
                this.m_ZoomablePreview.hRangeMax = 1f;
                this.m_ZoomablePreview.vRangeMax = 1f;
                this.m_ZoomablePreview.SetShownHRange(0.0f, 1f);
                this.m_ZoomablePreview.SetShownVRange(0.0f, 1f);
                this.m_ZoomablePreview.uniformScale    = true;
                this.m_ZoomablePreview.scaleWithWindow = true;
            }
            GUI.Box(r, string.Empty, (GUIStyle)"PreBackground");
            Rect position1 = new Rect(r);

            ++position1.y;
            position1.height = 18f;
            GUI.Box(position1, string.Empty, EditorStyles.toolbar);
            Rect position2 = new Rect(r);

            ++position2.y;
            position2.height = 18f;
            position2.width  = 120f;
            Rect rect1 = new Rect(r);

            rect1.yMin  += position2.height;
            rect1.yMax  -= 14f;
            rect1.width -= 11f;
            int selectedIndex = Array.IndexOf <GUIContent>(LightingWindowObjectTab.kObjectPreviewTextureOptions, this.m_SelectedObjectPreviewTexture);

            if (selectedIndex < 0)
            {
                selectedIndex = 0;
            }
            int index = EditorGUI.Popup(position2, selectedIndex, LightingWindowObjectTab.kObjectPreviewTextureOptions, EditorStyles.toolbarPopup);

            if (index >= LightingWindowObjectTab.kObjectPreviewTextureOptions.Length)
            {
                index = 0;
            }
            this.m_SelectedObjectPreviewTexture = LightingWindowObjectTab.kObjectPreviewTextureOptions[index];
            LightmapType       lightmapType = this.kObjectPreviewTextureTypes[index] == GITextureType.Baked || this.kObjectPreviewTextureTypes[index] == GITextureType.BakedDirectional ? LightmapType.StaticLightmap : LightmapType.DynamicLightmap;
            SerializedProperty property     = new SerializedObject(LightmapEditorSettings.GetLightmapSettings()).FindProperty("m_LightmapsMode");
            bool flag = (this.kObjectPreviewTextureTypes[index] == GITextureType.Baked || this.kObjectPreviewTextureTypes[index] == GITextureType.BakedDirectional) && property.intValue == 2;

            if (flag)
            {
                GUIContent content   = GUIContent.Temp("Indirect");
                Rect       position3 = position2;
                position3.x    += position2.width;
                position3.width = EditorStyles.toolbarButton.CalcSize(content).x;
                this.m_HasSeparateIndirectUV = GUI.Toggle(position3, this.m_HasSeparateIndirectUV, content.text, EditorStyles.toolbarButton);
            }
            switch (Event.current.type)
            {
            case EventType.ValidateCommand:
            case EventType.ExecuteCommand:
                if (Event.current.commandName == "FrameSelected")
                {
                    Vector4 lightmapTilingOffset = LightmapVisualizationUtility.GetLightmapTilingOffset(lightmapType);
                    Vector2 lhs1 = new Vector2(lightmapTilingOffset.z, lightmapTilingOffset.w);
                    Vector2 lhs2 = lhs1 + new Vector2(lightmapTilingOffset.x, lightmapTilingOffset.y);
                    lhs1 = Vector2.Max(lhs1, Vector2.zero);
                    Vector2 vector2 = Vector2.Min(lhs2, Vector2.one);
                    float   num1    = 1f - lhs1.y;
                    lhs1.y    = 1f - vector2.y;
                    vector2.y = num1;
                    Rect rect2 = new Rect(lhs1.x, lhs1.y, vector2.x - lhs1.x, vector2.y - lhs1.y);
                    rect2.x -= Mathf.Clamp(rect2.height - rect2.width, 0.0f, float.MaxValue) / 2f;
                    rect2.y -= Mathf.Clamp(rect2.width - rect2.height, 0.0f, float.MaxValue) / 2f;
                    // ISSUE: explicit reference operation
                    // ISSUE: variable of a reference type
                    Rect& local = @rect2;
                    float num2  = Mathf.Max(rect2.width, rect2.height);
                    rect2.height = num2;
                    double num3 = (double)num2;
                    // ISSUE: explicit reference operation
                    (^ local).width = (float)num3;
                    if (flag && this.m_HasSeparateIndirectUV)
                    {
                        rect2.x += 0.5f;
                    }
                    this.m_ZoomablePreview.shownArea = rect2;
                    Event.current.Use();
                    break;
                }
                break;

            case EventType.Repaint:
                Texture2D texture = texture2DList[index];
                if ((bool)((UnityEngine.Object)texture) && Event.current.type == EventType.Repaint)
                {
                    Rect position3 = new Rect(this.ScaleRectByZoomableArea(this.CenterToRect(this.ResizeRectToFit(new Rect(0.0f, 0.0f, (float)texture.width, (float)texture.height), rect1), rect1), this.m_ZoomablePreview));
                    position3.x += 3f;
                    position3.y += rect1.y + 20f;
                    Rect drawableArea = new Rect(rect1);
                    drawableArea.y += position2.height + 3f;
                    float num = drawableArea.y - 14f;
                    position3.y    -= num;
                    drawableArea.y -= num;
                    UnityEngine.FilterMode filterMode = texture.filterMode;
                    texture.filterMode = UnityEngine.FilterMode.Point;
                    GITextureType previewTextureType = this.kObjectPreviewTextureTypes[index];
                    bool          drawSpecularUV     = flag && this.m_HasSeparateIndirectUV;
                    LightmapVisualizationUtility.DrawTextureWithUVOverlay(texture, Selection.activeGameObject, drawableArea, position3, previewTextureType, drawSpecularUV);
                    texture.filterMode = filterMode;
                    break;
                }
                break;
            }
            if (this.m_PreviousSelection != Selection.activeInstanceID)
            {
                this.m_PreviousSelection = Selection.activeInstanceID;
                this.m_ZoomablePreview.SetShownHRange(0.0f, 1f);
                this.m_ZoomablePreview.SetShownVRange(0.0f, 1f);
            }
            Rect rect3 = new Rect(r);

            rect3.yMin += position2.height;
            this.m_ZoomablePreview.rect = rect3;
            this.m_ZoomablePreview.BeginViewGUI();
            this.m_ZoomablePreview.EndViewGUI();
            GUILayoutUtility.GetRect(r.width, r.height);
        }
        public void DrawCurveEditor(Rect animEditorRect, TimelineWindow.TimelineState state, Vector2 activeRange, bool loop, bool selected)
        {
            this.UpdateCurveEditorIfNeeded(state);
            ZoomableArea arg_29_0 = this.m_CurveEditor;
            float        num      = this.CalculateTopMargin(animEditorRect.get_height());

            this.m_CurveEditor.set_bottommargin(num);
            arg_29_0.set_topmargin(num);
            float num2 = state.TimeToPixel((double)this.m_DataSource.start) - animEditorRect.get_xMin();

            this.m_CurveEditor.set_rightmargin(0f);
            this.m_CurveEditor.set_leftmargin(num2);
            this.m_CurveEditor.set_rect(new Rect(0f, 0f, animEditorRect.get_width(), animEditorRect.get_height()));
            this.m_CurveEditor.SetShownHRangeInsideMargins(0f, (state.PixelToTime(animEditorRect.get_xMax()) - this.m_DataSource.start) * this.m_DataSource.timeScale);
            if (this.m_LastFrameRate != state.frameRate)
            {
                this.m_CurveEditor.get_hTicks().SetTickModulosForFrameRate(state.frameRate);
                this.m_LastFrameRate = state.frameRate;
            }
            CurveWrapper[] animationCurves = this.m_CurveEditor.get_animationCurves();
            for (int i = 0; i < animationCurves.Length; i++)
            {
                CurveWrapper curveWrapper = animationCurves[i];
                curveWrapper.get_renderer().SetWrap(0, (!loop) ? 0 : 2);
            }
            this.m_CurveEditor.BeginViewGUI();
            Color color = GUI.get_color();

            GUI.set_color(Color.get_white());
            GUI.BeginGroup(animEditorRect);
            Graphics.DrawLine(new Vector2(num2, 0f), new Vector2(num2, animEditorRect.get_height()), new Color(1f, 1f, 1f, 0.5f));
            float num3 = activeRange.x - animEditorRect.get_x();
            float num4 = activeRange.y - activeRange.x;

            if (selected)
            {
                Rect rect = new Rect(num3, 0f, num4, animEditorRect.get_height());
                ClipCurveEditor.DrawOutline(rect, 2f);
            }
            EditorGUI.BeginChangeCheck();
            Event current = Event.get_current();

            if (current.get_type() == 8 || current.get_type() == 7 || selected)
            {
                this.m_CurveEditor.CurveGUI();
            }
            this.m_CurveEditor.EndViewGUI();
            if (EditorGUI.EndChangeCheck())
            {
                this.OnCurvesUpdated();
            }
            Color colorInlineCurveOutOfRangeOverlay = DirectorStyles.Instance.customSkin.colorInlineCurveOutOfRangeOverlay;
            Rect  rect2 = new Rect(num2, 0f, num3 - num2, animEditorRect.get_height());

            EditorGUI.DrawRect(rect2, colorInlineCurveOutOfRangeOverlay);
            Rect rect3 = new Rect(num3 + num4, 0f, animEditorRect.get_width() - num3 - num4, animEditorRect.get_height());

            EditorGUI.DrawRect(rect3, colorInlineCurveOutOfRangeOverlay);
            GUI.set_color(color);
            GUI.EndGroup();
            Rect rect4 = animEditorRect;

            rect4.set_width(ClipCurveEditor.s_GridLabelWidth);
            float num5 = num2 - ClipCurveEditor.s_GridLabelWidth;

            if (num5 > 0f)
            {
                rect4.set_x(animEditorRect.get_x() + num5);
            }
            GUI.BeginGroup(rect4);
            this.m_CurveEditor.GridGUI();
            GUI.EndGroup();
        }
 private Rect ScaleRectByZoomableArea(Rect rect, ZoomableArea zoomableArea)
 {
     float num = -(zoomableArea.shownArea.x / zoomableArea.shownArea.width) * rect.width;
     float num2 = ((zoomableArea.shownArea.y - (1f - zoomableArea.shownArea.height)) / zoomableArea.shownArea.height) * rect.height;
     float width = rect.width / zoomableArea.shownArea.width;
     return new Rect(rect.x + num, rect.y + num2, width, rect.height / zoomableArea.shownArea.height);
 }
Beispiel #15
0
 private void InitIfNeeded(ProfilerWindow win)
 {
     if (this.m_ZoomablePreview == null)
     {
         this.m_ZoomablePreview = new ZoomableArea(true, false)
         {
             hRangeMin = 0f,
             vRangeMin = 0f,
             hRangeMax = 1f,
             vRangeMax = 1f
         };
         this.m_ZoomablePreview.SetShownHRange(0f, 1f);
         this.m_ZoomablePreview.SetShownVRange(0f, 1f);
         this.m_ZoomablePreview.uniformScale    = true;
         this.m_ZoomablePreview.scaleWithWindow = true;
         int num  = 100;
         int num2 = 200;
         this.m_MulticolumnHeaderState = new MultiColumnHeaderState(new MultiColumnHeaderState.Column[]
         {
             new MultiColumnHeaderState.Column
             {
                 headerContent = EditorGUIUtility.TrTextContent("Object", null, null),
                 width         = 220f,
                 maxWidth      = 400f,
                 canSort       = true
             },
             new MultiColumnHeaderState.Column
             {
                 headerContent = EditorGUIUtility.TrTextContent("Self Batch Count", null, null),
                 width         = (float)num,
                 maxWidth      = (float)num2
             },
             new MultiColumnHeaderState.Column
             {
                 headerContent = EditorGUIUtility.TrTextContent("Cumulative Batch Count", null, null),
                 width         = (float)num,
                 maxWidth      = (float)num2
             },
             new MultiColumnHeaderState.Column
             {
                 headerContent = EditorGUIUtility.TrTextContent("Self Vertex Count", null, null),
                 width         = (float)num,
                 maxWidth      = (float)num2
             },
             new MultiColumnHeaderState.Column
             {
                 headerContent = EditorGUIUtility.TrTextContent("Cumulative Vertex Count", null, null),
                 width         = (float)num,
                 maxWidth      = (float)num2
             },
             new MultiColumnHeaderState.Column
             {
                 headerContent = EditorGUIUtility.TrTextContent("Batch Breaking Reason", null, null),
                 width         = 220f,
                 maxWidth      = 400f,
                 canSort       = false
             },
             new MultiColumnHeaderState.Column
             {
                 headerContent = EditorGUIUtility.TrTextContent("GameObject Count", null, null),
                 width         = (float)num,
                 maxWidth      = 400f
             },
             new MultiColumnHeaderState.Column
             {
                 headerContent = EditorGUIUtility.TrTextContent("GameObjects", null, null),
                 width         = 150f,
                 maxWidth      = 400f,
                 canSort       = false
             }
         });
         MultiColumnHeaderState.Column[] columns = this.m_MulticolumnHeaderState.columns;
         for (int i = 0; i < columns.Length; i++)
         {
             MultiColumnHeaderState.Column column = columns[i];
             column.sortingArrowAlignment = TextAlignment.Right;
         }
         this.m_UGUIProfilerTreeViewState = new UISystemProfilerTreeView.State
         {
             profilerWindow = win
         };
         UISystemProfiler.Headers headers = new UISystemProfiler.Headers(this.m_MulticolumnHeaderState)
         {
             canSort = true,
             height  = 21f
         };
         headers.sortingChanged += delegate(MultiColumnHeader header)
         {
             this.m_TreeViewControl.Reload();
         };
         this.m_TreeViewControl = new UISystemProfilerTreeView(this.m_UGUIProfilerTreeViewState, headers);
         this.m_TreeViewControl.Reload();
     }
 }
Beispiel #16
0
 public void ObjectPreview(Rect r)
 {
     if (r.height > 0f)
     {
         List <Texture2D> list  = new List <Texture2D>();
         GITextureType[]  array = this.kObjectPreviewTextureTypes;
         for (int i = 0; i < array.Length; i++)
         {
             GITextureType textureType = array[i];
             list.Add(LightmapVisualizationUtility.GetGITexture(textureType));
         }
         if (list.Count != 0)
         {
             if (this.m_ZoomablePreview == null)
             {
                 this.m_ZoomablePreview           = new ZoomableArea(true);
                 this.m_ZoomablePreview.hRangeMin = 0f;
                 this.m_ZoomablePreview.vRangeMin = 0f;
                 this.m_ZoomablePreview.hRangeMax = 1f;
                 this.m_ZoomablePreview.vRangeMax = 1f;
                 this.m_ZoomablePreview.SetShownHRange(0f, 1f);
                 this.m_ZoomablePreview.SetShownVRange(0f, 1f);
                 this.m_ZoomablePreview.uniformScale    = true;
                 this.m_ZoomablePreview.scaleWithWindow = true;
             }
             GUI.Box(r, "", "PreBackground");
             Rect position = new Rect(r);
             position.y     += 1f;
             position.height = 18f;
             GUI.Box(position, "", EditorStyles.toolbar);
             Rect position2 = new Rect(r);
             position2.y     += 1f;
             position2.height = 18f;
             position2.width  = 120f;
             Rect rect = new Rect(r);
             rect.yMin  += position2.height;
             rect.yMax  -= 14f;
             rect.width -= 11f;
             int num = Array.IndexOf <GUIContent>(LightingWindowObjectTab.kObjectPreviewTextureOptions, this.m_SelectedObjectPreviewTexture);
             if (num < 0)
             {
                 num = 0;
             }
             num = EditorGUI.Popup(position2, num, LightingWindowObjectTab.kObjectPreviewTextureOptions, EditorStyles.toolbarPopup);
             if (num >= LightingWindowObjectTab.kObjectPreviewTextureOptions.Length)
             {
                 num = 0;
             }
             this.m_SelectedObjectPreviewTexture = LightingWindowObjectTab.kObjectPreviewTextureOptions[num];
             LightmapType lightmapType = (this.kObjectPreviewTextureTypes[num] != GITextureType.BakedShadowMask && this.kObjectPreviewTextureTypes[num] != GITextureType.Baked && this.kObjectPreviewTextureTypes[num] != GITextureType.BakedDirectional && this.kObjectPreviewTextureTypes[num] != GITextureType.BakedCharting) ? LightmapType.DynamicLightmap : LightmapType.StaticLightmap;
             Event        current      = Event.current;
             EventType    type         = current.type;
             if (type != EventType.ValidateCommand && type != EventType.ExecuteCommand)
             {
                 if (type == EventType.Repaint)
                 {
                     Texture2D texture2D = list[num];
                     if (texture2D && Event.current.type == EventType.Repaint)
                     {
                         Rect rect2 = new Rect(0f, 0f, (float)texture2D.width, (float)texture2D.height);
                         rect2 = this.ResizeRectToFit(rect2, rect);
                         rect2 = this.CenterToRect(rect2, rect);
                         rect2 = this.ScaleRectByZoomableArea(rect2, this.m_ZoomablePreview);
                         Rect position3 = new Rect(rect2);
                         position3.x += 3f;
                         position3.y += rect.y + 20f;
                         Rect drawableArea = new Rect(rect);
                         drawableArea.y += position2.height + 3f;
                         float num2 = drawableArea.y - 14f;
                         position3.y    -= num2;
                         drawableArea.y -= num2;
                         FilterMode filterMode = texture2D.filterMode;
                         texture2D.filterMode = FilterMode.Point;
                         GITextureType textureType2 = this.kObjectPreviewTextureTypes[num];
                         LightmapVisualizationUtility.DrawTextureWithUVOverlay(texture2D, Selection.activeGameObject, drawableArea, position3, textureType2);
                         texture2D.filterMode = filterMode;
                     }
                 }
             }
             else if (Event.current.commandName == "FrameSelected")
             {
                 Vector4 lightmapTilingOffset = LightmapVisualizationUtility.GetLightmapTilingOffset(lightmapType);
                 Vector2 vector = new Vector2(lightmapTilingOffset.z, lightmapTilingOffset.w);
                 Vector2 lhs    = vector + new Vector2(lightmapTilingOffset.x, lightmapTilingOffset.y);
                 vector = Vector2.Max(vector, Vector2.zero);
                 lhs    = Vector2.Min(lhs, Vector2.one);
                 float y = 1f - vector.y;
                 vector.y = 1f - lhs.y;
                 lhs.y    = y;
                 Rect shownArea = new Rect(vector.x, vector.y, lhs.x - vector.x, lhs.y - vector.y);
                 shownArea.x -= Mathf.Clamp(shownArea.height - shownArea.width, 0f, 3.40282347E+38f) / 2f;
                 shownArea.y -= Mathf.Clamp(shownArea.width - shownArea.height, 0f, 3.40282347E+38f) / 2f;
                 float num3 = Mathf.Max(shownArea.width, shownArea.height);
                 shownArea.height = num3;
                 shownArea.width  = num3;
                 this.m_ZoomablePreview.shownArea = shownArea;
                 Event.current.Use();
             }
             if (this.m_PreviousSelection != Selection.activeInstanceID)
             {
                 this.m_PreviousSelection = Selection.activeInstanceID;
                 this.m_ZoomablePreview.SetShownHRange(0f, 1f);
                 this.m_ZoomablePreview.SetShownVRange(0f, 1f);
             }
             Rect rect3 = new Rect(r);
             rect3.yMin += position2.height;
             this.m_ZoomablePreview.rect = rect3;
             this.m_ZoomablePreview.BeginViewGUI();
             this.m_ZoomablePreview.EndViewGUI();
             GUILayoutUtility.GetRect(r.width, r.height);
         }
     }
 }
 public void ObjectPreview(Rect r)
 {
   if ((double) r.height <= 0.0)
     return;
   if (LightingWindowObjectTab.s_Styles == null)
     LightingWindowObjectTab.s_Styles = new LightingWindowObjectTab.Styles();
   List<Texture2D> texture2DList = new List<Texture2D>();
   foreach (GITextureType previewTextureType in this.kObjectPreviewTextureTypes)
     texture2DList.Add(LightmapVisualizationUtility.GetGITexture(previewTextureType));
   if (texture2DList.Count == 0)
     return;
   if (this.m_ZoomablePreview == null)
   {
     this.m_ZoomablePreview = new ZoomableArea(true);
     this.m_ZoomablePreview.hRangeMin = 0.0f;
     this.m_ZoomablePreview.vRangeMin = 0.0f;
     this.m_ZoomablePreview.hRangeMax = 1f;
     this.m_ZoomablePreview.vRangeMax = 1f;
     this.m_ZoomablePreview.SetShownHRange(0.0f, 1f);
     this.m_ZoomablePreview.SetShownVRange(0.0f, 1f);
     this.m_ZoomablePreview.uniformScale = true;
     this.m_ZoomablePreview.scaleWithWindow = true;
   }
   GUI.Box(r, string.Empty, (GUIStyle) "PreBackground");
   Rect position1 = new Rect(r);
   ++position1.y;
   position1.height = 18f;
   GUI.Box(position1, string.Empty, EditorStyles.toolbar);
   Rect position2 = new Rect(r);
   ++position2.y;
   position2.height = 18f;
   position2.width = 120f;
   Rect rect1 = new Rect(r);
   rect1.yMin += position2.height;
   rect1.yMax -= 14f;
   rect1.width -= 11f;
   int selectedIndex = Array.IndexOf<GUIContent>(LightingWindowObjectTab.kObjectPreviewTextureOptions, this.m_SelectedObjectPreviewTexture);
   if (selectedIndex < 0)
     selectedIndex = 0;
   int index = EditorGUI.Popup(position2, selectedIndex, LightingWindowObjectTab.kObjectPreviewTextureOptions, EditorStyles.toolbarPopup);
   if (index >= LightingWindowObjectTab.kObjectPreviewTextureOptions.Length)
     index = 0;
   this.m_SelectedObjectPreviewTexture = LightingWindowObjectTab.kObjectPreviewTextureOptions[index];
   LightmapType lightmapType = this.kObjectPreviewTextureTypes[index] == GITextureType.Baked || this.kObjectPreviewTextureTypes[index] == GITextureType.BakedDirectional ? LightmapType.StaticLightmap : LightmapType.DynamicLightmap;
   SerializedProperty property = new SerializedObject(LightmapEditorSettings.GetLightmapSettings()).FindProperty("m_LightmapsMode");
   bool flag = (this.kObjectPreviewTextureTypes[index] == GITextureType.Baked || this.kObjectPreviewTextureTypes[index] == GITextureType.BakedDirectional) && property.intValue == 2;
   if (flag)
   {
     GUIContent content = GUIContent.Temp("Indirect");
     Rect position3 = position2;
     position3.x += position2.width;
     position3.width = EditorStyles.toolbarButton.CalcSize(content).x;
     this.m_HasSeparateIndirectUV = GUI.Toggle(position3, this.m_HasSeparateIndirectUV, content.text, EditorStyles.toolbarButton);
   }
   switch (Event.current.type)
   {
     case EventType.ValidateCommand:
     case EventType.ExecuteCommand:
       if (Event.current.commandName == "FrameSelected")
       {
         Vector4 lightmapTilingOffset = LightmapVisualizationUtility.GetLightmapTilingOffset(lightmapType);
         Vector2 lhs1 = new Vector2(lightmapTilingOffset.z, lightmapTilingOffset.w);
         Vector2 lhs2 = lhs1 + new Vector2(lightmapTilingOffset.x, lightmapTilingOffset.y);
         lhs1 = Vector2.Max(lhs1, Vector2.zero);
         Vector2 vector2 = Vector2.Min(lhs2, Vector2.one);
         float num1 = 1f - lhs1.y;
         lhs1.y = 1f - vector2.y;
         vector2.y = num1;
         Rect rect2 = new Rect(lhs1.x, lhs1.y, vector2.x - lhs1.x, vector2.y - lhs1.y);
         rect2.x -= Mathf.Clamp(rect2.height - rect2.width, 0.0f, float.MaxValue) / 2f;
         rect2.y -= Mathf.Clamp(rect2.width - rect2.height, 0.0f, float.MaxValue) / 2f;
         // ISSUE: explicit reference operation
         // ISSUE: variable of a reference type
         Rect& local = @rect2;
         float num2 = Mathf.Max(rect2.width, rect2.height);
         rect2.height = num2;
         double num3 = (double) num2;
         // ISSUE: explicit reference operation
         (^local).width = (float) num3;
         if (flag && this.m_HasSeparateIndirectUV)
           rect2.x += 0.5f;
         this.m_ZoomablePreview.shownArea = rect2;
         Event.current.Use();
         break;
       }
       break;
     case EventType.Repaint:
       Texture2D texture = texture2DList[index];
       if ((bool) ((UnityEngine.Object) texture) && Event.current.type == EventType.Repaint)
       {
         Rect position3 = new Rect(this.ScaleRectByZoomableArea(this.CenterToRect(this.ResizeRectToFit(new Rect(0.0f, 0.0f, (float) texture.width, (float) texture.height), rect1), rect1), this.m_ZoomablePreview));
         position3.x += 3f;
         position3.y += rect1.y + 20f;
         Rect drawableArea = new Rect(rect1);
         drawableArea.y += position2.height + 3f;
         float num = drawableArea.y - 14f;
         position3.y -= num;
         drawableArea.y -= num;
         UnityEngine.FilterMode filterMode = texture.filterMode;
         texture.filterMode = UnityEngine.FilterMode.Point;
         GITextureType previewTextureType = this.kObjectPreviewTextureTypes[index];
         bool drawSpecularUV = flag && this.m_HasSeparateIndirectUV;
         LightmapVisualizationUtility.DrawTextureWithUVOverlay(texture, Selection.activeGameObject, drawableArea, position3, previewTextureType, drawSpecularUV);
         texture.filterMode = filterMode;
         break;
       }
       break;
   }
   if (this.m_PreviousSelection != Selection.activeInstanceID)
   {
     this.m_PreviousSelection = Selection.activeInstanceID;
     this.m_ZoomablePreview.SetShownHRange(0.0f, 1f);
     this.m_ZoomablePreview.SetShownVRange(0.0f, 1f);
   }
   Rect rect3 = new Rect(r);
   rect3.yMin += position2.height;
   this.m_ZoomablePreview.rect = rect3;
   this.m_ZoomablePreview.BeginViewGUI();
   this.m_ZoomablePreview.EndViewGUI();
   GUILayoutUtility.GetRect(r.width, r.height);
 }
 private Rect ScaleRectByZoomableArea(Rect rect, ZoomableArea zoomableArea)
 {
   float num1 = (float) -((double) zoomableArea.shownArea.x / (double) zoomableArea.shownArea.width) * rect.width;
   float num2 = (zoomableArea.shownArea.y - (1f - zoomableArea.shownArea.height)) / zoomableArea.shownArea.height * rect.height;
   float width = rect.width / zoomableArea.shownArea.width;
   float height = rect.height / zoomableArea.shownArea.height;
   return new Rect(rect.x + num1, rect.y + num2, width, height);
 }
Beispiel #19
0
        public void ObjectPreview(Rect r)
        {
            if (r.height <= 0f)
            {
                return;
            }
            if (LightingWindowObjectTab.s_Styles == null)
            {
                LightingWindowObjectTab.s_Styles = new LightingWindowObjectTab.Styles();
            }
            List <Texture2D> list = new List <Texture2D>();

            GITextureType[] array = this.kObjectPreviewTextureTypes;
            for (int i = 0; i < array.Length; i++)
            {
                GITextureType textureType = array[i];
                list.Add(LightmapVisualizationUtility.GetGITexture(textureType));
            }
            if (list.Count == 0)
            {
                return;
            }
            if (this.m_ZoomablePreview == null)
            {
                this.m_ZoomablePreview           = new ZoomableArea(true);
                this.m_ZoomablePreview.hRangeMin = 0f;
                this.m_ZoomablePreview.vRangeMin = 0f;
                this.m_ZoomablePreview.hRangeMax = 1f;
                this.m_ZoomablePreview.vRangeMax = 1f;
                this.m_ZoomablePreview.SetShownHRange(0f, 1f);
                this.m_ZoomablePreview.SetShownVRange(0f, 1f);
                this.m_ZoomablePreview.uniformScale    = true;
                this.m_ZoomablePreview.scaleWithWindow = true;
            }
            GUI.Box(r, string.Empty, "PreBackground");
            Rect position = new Rect(r);

            position.y     += 1f;
            position.height = 18f;
            GUI.Box(position, string.Empty, EditorStyles.toolbar);
            Rect rect = new Rect(r);

            rect.y     += 1f;
            rect.height = 18f;
            rect.width  = 120f;
            Rect rect2 = new Rect(r);

            rect2.yMin  += rect.height;
            rect2.yMax  -= 14f;
            rect2.width -= 11f;
            int num = Array.IndexOf <GUIContent>(LightingWindowObjectTab.kObjectPreviewTextureOptions, this.m_SelectedObjectPreviewTexture);

            if (num < 0)
            {
                num = 0;
            }
            num = EditorGUI.Popup(rect, num, LightingWindowObjectTab.kObjectPreviewTextureOptions, EditorStyles.toolbarPopup);
            if (num >= LightingWindowObjectTab.kObjectPreviewTextureOptions.Length)
            {
                num = 0;
            }
            this.m_SelectedObjectPreviewTexture = LightingWindowObjectTab.kObjectPreviewTextureOptions[num];
            LightmapType       lightmapType       = (this.kObjectPreviewTextureTypes[num] != GITextureType.Baked && this.kObjectPreviewTextureTypes[num] != GITextureType.BakedDirectional) ? LightmapType.DynamicLightmap : LightmapType.StaticLightmap;
            SerializedObject   serializedObject   = new SerializedObject(LightmapEditorSettings.GetLightmapSettings());
            SerializedProperty serializedProperty = serializedObject.FindProperty("m_LightmapsMode");
            bool flag = (this.kObjectPreviewTextureTypes[num] == GITextureType.Baked || this.kObjectPreviewTextureTypes[num] == GITextureType.BakedDirectional) && serializedProperty.intValue == 2;

            if (flag)
            {
                GUIContent gUIContent = GUIContent.Temp("Indirect");
                Rect       position2  = rect;
                position2.x    += rect.width;
                position2.width = EditorStyles.toolbarButton.CalcSize(gUIContent).x;
                this.m_HasSeparateIndirectUV = GUI.Toggle(position2, this.m_HasSeparateIndirectUV, gUIContent.text, EditorStyles.toolbarButton);
            }
            Event     current = Event.current;
            EventType type    = current.type;

            if (type != EventType.ValidateCommand && type != EventType.ExecuteCommand)
            {
                if (type == EventType.Repaint)
                {
                    Texture2D texture2D = list[num];
                    if (texture2D && Event.current.type == EventType.Repaint)
                    {
                        Rect rect3 = new Rect(0f, 0f, (float)texture2D.width, (float)texture2D.height);
                        rect3 = this.ResizeRectToFit(rect3, rect2);
                        rect3 = this.CenterToRect(rect3, rect2);
                        rect3 = this.ScaleRectByZoomableArea(rect3, this.m_ZoomablePreview);
                        Rect position3 = new Rect(rect3);
                        position3.x += 3f;
                        position3.y += rect2.y + 20f;
                        Rect drawableArea = new Rect(rect2);
                        drawableArea.y += rect.height + 3f;
                        float num2 = drawableArea.y - 14f;
                        position3.y         -= num2;
                        drawableArea.y      -= num2;
                        texture2D.filterMode = FilterMode.Point;
                        GITextureType textureType2   = this.kObjectPreviewTextureTypes[num];
                        bool          drawSpecularUV = flag && this.m_HasSeparateIndirectUV;
                        LightmapVisualizationUtility.DrawTextureWithUVOverlay(texture2D, Selection.activeGameObject, drawableArea, position3, textureType2, drawSpecularUV);
                    }
                }
            }
            else
            {
                if (Event.current.commandName == "FrameSelected")
                {
                    Vector4 lightmapTilingOffset = LightmapVisualizationUtility.GetLightmapTilingOffset(lightmapType);
                    Vector2 vector = new Vector2(lightmapTilingOffset.z, lightmapTilingOffset.w);
                    Vector2 lhs    = vector + new Vector2(lightmapTilingOffset.x, lightmapTilingOffset.y);
                    vector = Vector2.Max(vector, Vector2.zero);
                    lhs    = Vector2.Min(lhs, Vector2.one);
                    float y = 1f - vector.y;
                    vector.y = 1f - lhs.y;
                    lhs.y    = y;
                    Rect shownArea = new Rect(vector.x, vector.y, lhs.x - vector.x, lhs.y - vector.y);
                    shownArea.x -= Mathf.Clamp(shownArea.height - shownArea.width, 0f, 3.40282347E+38f) / 2f;
                    shownArea.y -= Mathf.Clamp(shownArea.width - shownArea.height, 0f, 3.40282347E+38f) / 2f;
                    float num3 = Mathf.Max(shownArea.width, shownArea.height);
                    shownArea.height = num3;
                    shownArea.width  = num3;
                    if (flag && this.m_HasSeparateIndirectUV)
                    {
                        shownArea.x += 0.5f;
                    }
                    this.m_ZoomablePreview.shownArea = shownArea;
                    Event.current.Use();
                }
            }
            if (this.m_PreviousSelection != Selection.activeInstanceID)
            {
                this.m_PreviousSelection = Selection.activeInstanceID;
                this.m_ZoomablePreview.SetShownHRange(0f, 1f);
                this.m_ZoomablePreview.SetShownVRange(0f, 1f);
            }
            Rect rect4 = new Rect(r);

            rect4.yMin += rect.height;
            this.m_ZoomablePreview.rect = rect4;
            this.m_ZoomablePreview.BeginViewGUI();
            this.m_ZoomablePreview.EndViewGUI();
            GUILayoutUtility.GetRect(r.width, r.height);
        }
Beispiel #20
0
 private void InitializeZoomArea()
 {
     this.m_ZoomArea = new ZoomableArea(true, false);
     this.m_ZoomArea.uniformScale = true;
     this.m_ZoomArea.upDirection = ZoomableArea.YDirection.Negative;
 }
        public void ObjectPreview(Rect r)
        {
            if (r.height <= 0)
            {
                return;
            }

            if (m_ZoomablePreview == null)
            {
                m_ZoomablePreview = new ZoomableArea(true);

                m_ZoomablePreview.hRangeMin = 0.0f;
                m_ZoomablePreview.vRangeMin = 0.0f;

                m_ZoomablePreview.hRangeMax = 1.0f;
                m_ZoomablePreview.vRangeMax = 1.0f;

                m_ZoomablePreview.SetShownHRange(0, 1);
                m_ZoomablePreview.SetShownVRange(0, 1);

                m_ZoomablePreview.uniformScale    = true;
                m_ZoomablePreview.scaleWithWindow = true;
            }

            // Draw background
            GUI.Box(r, "", "PreBackground");

            // Top menu rect
            Rect menuRect = new Rect(r);

            menuRect.y     += 1;
            menuRect.height = 18;
            GUI.Box(menuRect, "", EditorStyles.toolbar);

            // Top menu dropdown
            Rect dropRect = new Rect(r);

            dropRect.y     += 1;
            dropRect.height = 18;
            dropRect.width  = 120;

            // Drawable area
            Rect drawableArea = new Rect(r);

            drawableArea.yMin  += dropRect.height;
            drawableArea.yMax  -= 14;
            drawableArea.width -= 11;

            int index = Array.IndexOf(Styles.ObjectPreviewTextureOptions, m_SelectedObjectPreviewTexture);

            if (index < 0 || !LightmapVisualizationUtility.IsTextureTypeEnabled(kObjectPreviewTextureTypes[index]))
            {
                index = 0;
                m_SelectedObjectPreviewTexture = Styles.ObjectPreviewTextureOptions[index];
            }

            if (EditorGUI.DropdownButton(dropRect, m_SelectedObjectPreviewTexture, FocusType.Passive, EditorStyles.toolbarPopup))
            {
                GenericMenu menu = new GenericMenu();

                for (int i = 0; i < Styles.ObjectPreviewTextureOptions.Length; i++)
                {
                    if (LightmapVisualizationUtility.IsTextureTypeEnabled(kObjectPreviewTextureTypes[i]))
                    {
                        menu.AddItem(Styles.ObjectPreviewTextureOptions[i], index == i, SelectPreviewTextureOption, Styles.ObjectPreviewTextureOptions.ElementAt(i));
                    }
                    else
                    {
                        menu.AddDisabledItem(Styles.ObjectPreviewTextureOptions.ElementAt(i));
                    }
                }
                menu.DropDown(dropRect);
            }

            GITextureType textureType = kObjectPreviewTextureTypes[Array.IndexOf(Styles.ObjectPreviewTextureOptions, m_SelectedObjectPreviewTexture)];

            if (m_CachedTexture.type != textureType || m_CachedTexture.contentHash != LightmapVisualizationUtility.GetSelectedObjectGITextureHash(textureType) || m_CachedTexture.contentHash == new Hash128())
            {
                m_CachedTexture = LightmapVisualizationUtility.GetSelectedObjectGITexture(textureType);
            }

            if (m_CachedTexture.textureAvailability == GITextureAvailability.GITextureNotAvailable || m_CachedTexture.textureAvailability == GITextureAvailability.GITextureUnknown)
            {
                if (LightmapVisualizationUtility.IsBakedTextureType(textureType))
                {
                    if (textureType == GITextureType.BakedShadowMask)
                    {
                        GUI.Label(drawableArea, Styles.TextureNotAvailableBakedShadowmask);
                    }
                    else
                    {
                        GUI.Label(drawableArea, Styles.TextureNotAvailableBaked);
                    }
                }
                else
                {
                    GUI.Label(drawableArea, Styles.TextureNotAvailableRealtime);
                }

                return;
            }

            if (m_CachedTexture.textureAvailability == GITextureAvailability.GITextureLoading && m_CachedTexture.texture == null)
            {
                GUI.Label(drawableArea, Styles.TextureLoading);

                return;
            }

            LightmapType lightmapType = LightmapVisualizationUtility.GetLightmapType(textureType);

            // Framing and drawing
            var evt = Event.current;

            switch (evt.type)
            {
            // 'F' will zoom to uv bounds
            case EventType.ValidateCommand:
            case EventType.ExecuteCommand:

                if (Event.current.commandName == EventCommandNames.FrameSelected)
                {
                    Vector4 lightmapTilingOffset = LightmapVisualizationUtility.GetLightmapTilingOffset(lightmapType);

                    Vector2 min = new Vector2(lightmapTilingOffset.z, lightmapTilingOffset.w);
                    Vector2 max = min + new Vector2(lightmapTilingOffset.x, lightmapTilingOffset.y);

                    min = Vector2.Max(min, Vector2.zero);
                    max = Vector2.Min(max, Vector2.one);

                    float swap = 1f - min.y;
                    min.y = 1f - max.y;
                    max.y = swap;

                    // Make sure that the focus rectangle is a even square
                    Rect rect = new Rect(min.x, min.y, max.x - min.x, max.y - min.y);
                    rect.x    -= Mathf.Clamp(rect.height - rect.width, 0, float.MaxValue) / 2;
                    rect.y    -= Mathf.Clamp(rect.width - rect.height, 0, float.MaxValue) / 2;
                    rect.width = rect.height = Mathf.Max(rect.width, rect.height);

                    m_ZoomablePreview.shownArea = rect;
                    Event.current.Use();
                }
                break;

            // Scale and draw texture and uv's
            case EventType.Repaint:

                Texture2D texture = m_CachedTexture.texture;
                if (texture && Event.current.type == EventType.Repaint)
                {
                    Rect textureRect = new Rect(0, 0, texture.width, texture.height);
                    textureRect = ResizeRectToFit(textureRect, drawableArea);
                    //textureRect.x = -textureRect.width / 2;
                    //textureRect.y = -textureRect.height / 2;
                    textureRect = CenterToRect(textureRect, drawableArea);
                    textureRect = ScaleRectByZoomableArea(textureRect, m_ZoomablePreview);

                    // Draw texture and UV
                    Rect uvRect = new Rect(textureRect);
                    uvRect.x += 3;
                    uvRect.y += drawableArea.y + 20;

                    Rect clipRect = new Rect(drawableArea);
                    clipRect.y += dropRect.height + 3;

                    // fix 635838 - We need to offset the rects for rendering.
                    {
                        float offset = clipRect.y - 14;
                        uvRect.y   -= offset;
                        clipRect.y -= offset;
                    }

                    // Texture shouldn't be filtered since it will make previewing really blurry
                    FilterMode prevMode = texture.filterMode;
                    texture.filterMode = FilterMode.Point;

                    LightmapVisualizationUtility.DrawTextureWithUVOverlay(texture, Selection.activeGameObject, clipRect, uvRect, textureType);
                    texture.filterMode = prevMode;
                }
                break;
            }

            // Reset zoom if selection is changed
            if (m_PreviousSelection != Selection.activeInstanceID)
            {
                m_PreviousSelection = Selection.activeInstanceID;
                m_ZoomablePreview.SetShownHRange(0, 1);
                m_ZoomablePreview.SetShownVRange(0, 1);
            }

            // Handle zoomable area
            Rect zoomRect = new Rect(r);

            zoomRect.yMin         += dropRect.height;
            m_ZoomablePreview.rect = zoomRect;

            m_ZoomablePreview.BeginViewGUI();
            m_ZoomablePreview.EndViewGUI();

            GUILayoutUtility.GetRect(r.width, r.height);
        }
        public void ObjectPreview(Rect r)
        {
            if (r.height > 0f)
            {
                if (s_Styles == null)
                {
                    s_Styles = new Styles();
                }
                List<Texture2D> list = new List<Texture2D>();
                foreach (GITextureType type in this.kObjectPreviewTextureTypes)
                {
                    list.Add(LightmapVisualizationUtility.GetGITexture(type));
                }
                if (list.Count != 0)
                {
                    if (this.m_ZoomablePreview == null)
                    {
                        this.m_ZoomablePreview = new ZoomableArea(true);
                        this.m_ZoomablePreview.hRangeMin = 0f;
                        this.m_ZoomablePreview.vRangeMin = 0f;
                        this.m_ZoomablePreview.hRangeMax = 1f;
                        this.m_ZoomablePreview.vRangeMax = 1f;
                        this.m_ZoomablePreview.SetShownHRange(0f, 1f);
                        this.m_ZoomablePreview.SetShownVRange(0f, 1f);
                        this.m_ZoomablePreview.uniformScale = true;
                        this.m_ZoomablePreview.scaleWithWindow = true;
                    }
                    GUI.Box(r, "", "PreBackground");
                    Rect position = new Rect(r);
                    position.y++;
                    position.height = 18f;
                    GUI.Box(position, "", EditorStyles.toolbar);
                    Rect rect2 = new Rect(r);
                    rect2.y++;
                    rect2.height = 18f;
                    rect2.width = 120f;
                    Rect to = new Rect(r);
                    to.yMin += rect2.height;
                    to.yMax -= 14f;
                    to.width -= 11f;
                    int index = Array.IndexOf<GUIContent>(kObjectPreviewTextureOptions, this.m_SelectedObjectPreviewTexture);
                    if (index < 0)
                    {
                        index = 0;
                    }
                    index = EditorGUI.Popup(rect2, index, kObjectPreviewTextureOptions, EditorStyles.toolbarPopup);
                    if (index >= kObjectPreviewTextureOptions.Length)
                    {
                        index = 0;
                    }
                    this.m_SelectedObjectPreviewTexture = kObjectPreviewTextureOptions[index];
                    LightmapType lightmapType = ((this.kObjectPreviewTextureTypes[index] != GITextureType.Baked) && (this.kObjectPreviewTextureTypes[index] != GITextureType.BakedDirectional)) ? LightmapType.DynamicLightmap : LightmapType.StaticLightmap;
                    bool flag = ((this.kObjectPreviewTextureTypes[index] == GITextureType.Baked) || (this.kObjectPreviewTextureTypes[index] == GITextureType.BakedDirectional)) && (LightmapSettings.lightmapsMode == LightmapsMode.SeparateDirectional);
                    if (flag)
                    {
                        GUIContent content = GUIContent.Temp("Indirect");
                        Rect rect4 = rect2;
                        rect4.x += rect2.width;
                        rect4.width = EditorStyles.toolbarButton.CalcSize(content).x;
                        this.m_HasSeparateIndirectUV = GUI.Toggle(rect4, this.m_HasSeparateIndirectUV, content.text, EditorStyles.toolbarButton);
                    }
                    switch (Event.current.type)
                    {
                        case EventType.ValidateCommand:
                        case EventType.ExecuteCommand:
                            if (Event.current.commandName == "FrameSelected")
                            {
                                Vector4 lightmapTilingOffset = LightmapVisualizationUtility.GetLightmapTilingOffset(lightmapType);
                                Vector2 lhs = new Vector2(lightmapTilingOffset.z, lightmapTilingOffset.w);
                                Vector2 vector4 = lhs + new Vector2(lightmapTilingOffset.x, lightmapTilingOffset.y);
                                lhs = Vector2.Max(lhs, Vector2.zero);
                                vector4 = Vector2.Min(vector4, Vector2.one);
                                float num3 = 1f - lhs.y;
                                lhs.y = 1f - vector4.y;
                                vector4.y = num3;
                                Rect rect5 = new Rect(lhs.x, lhs.y, vector4.x - lhs.x, vector4.y - lhs.y);
                                rect5.x -= Mathf.Clamp(rect5.height - rect5.width, 0f, float.MaxValue) / 2f;
                                rect5.y -= Mathf.Clamp(rect5.width - rect5.height, 0f, float.MaxValue) / 2f;
                                float num4 = Mathf.Max(rect5.width, rect5.height);
                                rect5.height = num4;
                                rect5.width = num4;
                                if (flag && this.m_HasSeparateIndirectUV)
                                {
                                    rect5.x += 0.5f;
                                }
                                this.m_ZoomablePreview.shownArea = rect5;
                                Event.current.Use();
                            }
                            break;

                        case EventType.Repaint:
                        {
                            Texture2D texture = list[index];
                            if ((texture != null) && (Event.current.type == EventType.Repaint))
                            {
                                Rect rect = new Rect(0f, 0f, (float) texture.width, (float) texture.height);
                                rect = this.ResizeRectToFit(rect, to);
                                rect = this.CenterToRect(rect, to);
                                rect = this.ScaleRectByZoomableArea(rect, this.m_ZoomablePreview);
                                Rect rect7 = new Rect(rect);
                                rect7.x += 3f;
                                rect7.y += to.y + 20f;
                                Rect drawableArea = new Rect(to);
                                drawableArea.y += rect2.height + 3f;
                                float num5 = drawableArea.y - 14f;
                                rect7.y -= num5;
                                drawableArea.y -= num5;
                                FilterMode filterMode = texture.filterMode;
                                texture.filterMode = FilterMode.Point;
                                GITextureType textureType = this.kObjectPreviewTextureTypes[index];
                                bool drawSpecularUV = flag && this.m_HasSeparateIndirectUV;
                                LightmapVisualizationUtility.DrawTextureWithUVOverlay(texture, Selection.activeGameObject, drawableArea, rect7, textureType, drawSpecularUV);
                                texture.filterMode = filterMode;
                            }
                            break;
                        }
                    }
                    if (this.m_PreviousSelection != Selection.activeInstanceID)
                    {
                        this.m_PreviousSelection = Selection.activeInstanceID;
                        this.m_ZoomablePreview.SetShownHRange(0f, 1f);
                        this.m_ZoomablePreview.SetShownVRange(0f, 1f);
                    }
                    Rect rect9 = new Rect(r);
                    rect9.yMin += rect2.height;
                    this.m_ZoomablePreview.rect = rect9;
                    this.m_ZoomablePreview.BeginViewGUI();
                    this.m_ZoomablePreview.EndViewGUI();
                    GUILayoutUtility.GetRect(r.width, r.height);
                }
            }
        }
        private void InitIfNeeded(ProfilerWindow win)
        {
            if (m_ZoomablePreview != null)
            {
                return;
            }

            m_ZoomablePreview = new ZoomableArea(true, false)
            {
                hRangeMin = 0.0f,
                vRangeMin = 0.0f,
                hRangeMax = 1.0f,
                vRangeMax = 1.0f
            };

            m_ZoomablePreview.SetShownHRange(0, 1);
            m_ZoomablePreview.SetShownVRange(0, 1);

            m_ZoomablePreview.uniformScale    = true;
            m_ZoomablePreview.scaleWithWindow = true;

            var initwidth = 100;
            var maxWidth  = 200;

            m_MulticolumnHeaderState = new MultiColumnHeaderState(new[]
            {
                new MultiColumnHeaderState.Column {
                    headerContent = EditorGUIUtility.TrTextContent("Object"), width = 220, maxWidth = 400, canSort = true
                },
                new MultiColumnHeaderState.Column {
                    headerContent = EditorGUIUtility.TrTextContent("Self Batch Count"), width = initwidth, maxWidth = maxWidth
                },
                new MultiColumnHeaderState.Column {
                    headerContent = EditorGUIUtility.TrTextContent("Cumulative Batch Count"), width = initwidth, maxWidth = maxWidth
                },
                new MultiColumnHeaderState.Column {
                    headerContent = EditorGUIUtility.TrTextContent("Self Vertex Count"), width = initwidth, maxWidth = maxWidth
                },
                new MultiColumnHeaderState.Column {
                    headerContent = EditorGUIUtility.TrTextContent("Cumulative Vertex Count"), width = initwidth, maxWidth = maxWidth
                },
                new MultiColumnHeaderState.Column
                {
                    headerContent = EditorGUIUtility.TrTextContent("Batch Breaking Reason"),
                    width         = 220,
                    maxWidth      = 400,
                    canSort       = false
                },
                new MultiColumnHeaderState.Column {
                    headerContent = EditorGUIUtility.TrTextContent("GameObject Count"), width = initwidth, maxWidth = 400
                },
                new MultiColumnHeaderState.Column {
                    headerContent = EditorGUIUtility.TrTextContent("GameObjects"), width = 150, maxWidth = 400, canSort = false
                },
            });
            foreach (var column in m_MulticolumnHeaderState.columns)
            {
                column.sortingArrowAlignment = TextAlignment.Right;
            }

            m_UGUIProfilerTreeViewState = new UISystemProfilerTreeView.State {
                profilerWindow = win
            };
            var multiColumnHeader = new Headers(m_MulticolumnHeaderState)
            {
                canSort = true, height = 21
            };

            multiColumnHeader.sortingChanged += header => { m_TreeViewControl.Reload(); };
            m_TreeViewControl = new UISystemProfilerTreeView(m_UGUIProfilerTreeViewState, multiColumnHeader);
            m_TreeViewControl.Reload();
        }
		public void ObjectPreview(Rect r)
		{
			if (r.height <= 0f)
			{
				return;
			}
			if (LightingWindowObjectTab.s_Styles == null)
			{
				LightingWindowObjectTab.s_Styles = new LightingWindowObjectTab.Styles();
			}
			List<Texture2D> list = new List<Texture2D>();
			GITextureType[] array = this.kObjectPreviewTextureTypes;
			for (int i = 0; i < array.Length; i++)
			{
				GITextureType textureType = array[i];
				list.Add(LightmapVisualizationUtility.GetGITexture(textureType));
			}
			if (list.Count == 0)
			{
				return;
			}
			if (this.m_ZoomablePreview == null)
			{
				this.m_ZoomablePreview = new ZoomableArea(true);
				this.m_ZoomablePreview.hRangeMin = 0f;
				this.m_ZoomablePreview.vRangeMin = 0f;
				this.m_ZoomablePreview.hRangeMax = 1f;
				this.m_ZoomablePreview.vRangeMax = 1f;
				this.m_ZoomablePreview.SetShownHRange(0f, 1f);
				this.m_ZoomablePreview.SetShownVRange(0f, 1f);
				this.m_ZoomablePreview.uniformScale = true;
				this.m_ZoomablePreview.scaleWithWindow = true;
			}
			GUI.Box(r, string.Empty, "PreBackground");
			Rect position = new Rect(r);
			position.y += 1f;
			position.height = 18f;
			GUI.Box(position, string.Empty, EditorStyles.toolbar);
			Rect rect = new Rect(r);
			rect.y += 1f;
			rect.height = 18f;
			rect.width = 120f;
			Rect rect2 = new Rect(r);
			rect2.yMin += rect.height;
			rect2.yMax -= 14f;
			rect2.width -= 11f;
			int num = Array.IndexOf<GUIContent>(LightingWindowObjectTab.kObjectPreviewTextureOptions, this.m_SelectedObjectPreviewTexture);
			if (num < 0)
			{
				num = 0;
			}
			num = EditorGUI.Popup(rect, num, LightingWindowObjectTab.kObjectPreviewTextureOptions, EditorStyles.toolbarPopup);
			if (num >= LightingWindowObjectTab.kObjectPreviewTextureOptions.Length)
			{
				num = 0;
			}
			this.m_SelectedObjectPreviewTexture = LightingWindowObjectTab.kObjectPreviewTextureOptions[num];
			LightmapType lightmapType = (this.kObjectPreviewTextureTypes[num] != GITextureType.Baked && this.kObjectPreviewTextureTypes[num] != GITextureType.BakedDirectional) ? LightmapType.DynamicLightmap : LightmapType.StaticLightmap;
			SerializedObject serializedObject = new SerializedObject(LightmapEditorSettings.GetLightmapSettings());
			SerializedProperty serializedProperty = serializedObject.FindProperty("m_LightmapsMode");
			bool flag = (this.kObjectPreviewTextureTypes[num] == GITextureType.Baked || this.kObjectPreviewTextureTypes[num] == GITextureType.BakedDirectional) && serializedProperty.intValue == 2;
			if (flag)
			{
				GUIContent gUIContent = GUIContent.Temp("Indirect");
				Rect position2 = rect;
				position2.x += rect.width;
				position2.width = EditorStyles.toolbarButton.CalcSize(gUIContent).x;
				this.m_HasSeparateIndirectUV = GUI.Toggle(position2, this.m_HasSeparateIndirectUV, gUIContent.text, EditorStyles.toolbarButton);
			}
			Event current = Event.current;
			EventType type = current.type;
			if (type != EventType.ValidateCommand && type != EventType.ExecuteCommand)
			{
				if (type == EventType.Repaint)
				{
					Texture2D texture2D = list[num];
					if (texture2D && Event.current.type == EventType.Repaint)
					{
						Rect rect3 = new Rect(0f, 0f, (float)texture2D.width, (float)texture2D.height);
						rect3 = this.ResizeRectToFit(rect3, rect2);
						rect3 = this.CenterToRect(rect3, rect2);
						rect3 = this.ScaleRectByZoomableArea(rect3, this.m_ZoomablePreview);
						Rect position3 = new Rect(rect3);
						position3.x += 3f;
						position3.y += rect2.y + 20f;
						Rect drawableArea = new Rect(rect2);
						drawableArea.y += rect.height + 3f;
						float num2 = drawableArea.y - 14f;
						position3.y -= num2;
						drawableArea.y -= num2;
						texture2D.filterMode = FilterMode.Point;
						GITextureType textureType2 = this.kObjectPreviewTextureTypes[num];
						bool drawSpecularUV = flag && this.m_HasSeparateIndirectUV;
						LightmapVisualizationUtility.DrawTextureWithUVOverlay(texture2D, Selection.activeGameObject, drawableArea, position3, textureType2, drawSpecularUV);
					}
				}
			}
			else
			{
				if (Event.current.commandName == "FrameSelected")
				{
					Vector4 lightmapTilingOffset = LightmapVisualizationUtility.GetLightmapTilingOffset(lightmapType);
					Vector2 vector = new Vector2(lightmapTilingOffset.z, lightmapTilingOffset.w);
					Vector2 lhs = vector + new Vector2(lightmapTilingOffset.x, lightmapTilingOffset.y);
					vector = Vector2.Max(vector, Vector2.zero);
					lhs = Vector2.Min(lhs, Vector2.one);
					float y = 1f - vector.y;
					vector.y = 1f - lhs.y;
					lhs.y = y;
					Rect shownArea = new Rect(vector.x, vector.y, lhs.x - vector.x, lhs.y - vector.y);
					shownArea.x -= Mathf.Clamp(shownArea.height - shownArea.width, 0f, 3.40282347E+38f) / 2f;
					shownArea.y -= Mathf.Clamp(shownArea.width - shownArea.height, 0f, 3.40282347E+38f) / 2f;
					float num3 = Mathf.Max(shownArea.width, shownArea.height);
					shownArea.height = num3;
					shownArea.width = num3;
					if (flag && this.m_HasSeparateIndirectUV)
					{
						shownArea.x += 0.5f;
					}
					this.m_ZoomablePreview.shownArea = shownArea;
					Event.current.Use();
				}
			}
			if (this.m_PreviousSelection != Selection.activeInstanceID)
			{
				this.m_PreviousSelection = Selection.activeInstanceID;
				this.m_ZoomablePreview.SetShownHRange(0f, 1f);
				this.m_ZoomablePreview.SetShownVRange(0f, 1f);
			}
			Rect rect4 = new Rect(r);
			rect4.yMin += rect.height;
			this.m_ZoomablePreview.rect = rect4;
			this.m_ZoomablePreview.BeginViewGUI();
			this.m_ZoomablePreview.EndViewGUI();
			GUILayoutUtility.GetRect(r.width, r.height);
		}