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);
}
}
}