public void OnPreviewSettings(UnityEngine.Object[] targets) { if (ShaderUtil.hardwareSupportsRectRenderTexture) { GUI.enabled = true; this.InitPreview(); bool flag = true; bool flag2 = true; bool flag3 = false; int a = 8; foreach (Texture texture in targets) { a = Mathf.Max(a, TextureUtil.GetMipmapCount(texture)); Cubemap cubemap = texture as Cubemap; if (cubemap != null) { TextureFormat format = cubemap.format; if (!TextureUtil.IsAlphaOnlyTextureFormat(format)) { flag2 = false; } if (TextureUtil.HasAlphaTextureFormat(format) && (TextureUtil.GetUsageMode(texture) == TextureUsageMode.Default)) { flag3 = true; } } else { flag3 = true; flag2 = false; } } if (flag2) { this.m_PreviewType = PreviewType.Alpha; flag = false; } else if (!flag3) { this.m_PreviewType = PreviewType.RGB; flag = false; } if (flag) { GUIContent[] contentArray = new GUIContent[] { Styles.RGBIcon, Styles.alphaIcon }; int previewType = (int)this.m_PreviewType; if (GUILayout.Button(contentArray[previewType], Styles.preButton, new GUILayoutOption[0])) { this.m_PreviewType = (PreviewType)(++previewType % contentArray.Length); } } GUI.enabled = a != 1; GUILayout.Box(Styles.smallZoom, Styles.preLabel, new GUILayoutOption[0]); GUI.changed = false; GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.MaxWidth(64f) }; this.m_MipLevel = Mathf.Round(GUILayout.HorizontalSlider(this.m_MipLevel, (float)(a - 1), 0f, Styles.preSlider, Styles.preSliderThumb, options)); GUILayout.Box(Styles.largeZoom, Styles.preLabel, new GUILayoutOption[0]); GUI.enabled = true; } }
private void OnGUI() { EditorGUIUtility.labelWidth = (base.position.width - 64f) - 20f; bool flag = true; this.m_ScrollPosition = EditorGUILayout.BeginVerticalScrollView(this.m_ScrollPosition, false, GUI.skin.verticalScrollbar, GUI.skin.scrollView, new GUILayoutOption[0]); flag &= this.ValidateTerrain(); EditorGUI.BeginChangeCheck(); GUILayout.BeginHorizontal(new GUILayoutOption[0]); string label = ""; float alignmentOffset = 0f; switch (this.m_Terrain.materialType) { case Terrain.MaterialType.BuiltInStandard: label = " Albedo (RGB)\nSmoothness (A)"; alignmentOffset = 15f; break; case Terrain.MaterialType.BuiltInLegacyDiffuse: label = "\n Diffuse (RGB)"; alignmentOffset = 15f; break; case Terrain.MaterialType.BuiltInLegacySpecular: label = "Diffuse (RGB)\n Gloss (A)"; alignmentOffset = 12f; break; case Terrain.MaterialType.Custom: label = " \n Splat"; alignmentOffset = 0f; break; } TextureFieldGUI(label, ref this.m_Texture, alignmentOffset); TextureFieldGUI("\nNormal", ref this.m_NormalMap, -4f); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); flag &= this.ValidateMainTexture(this.m_Texture); if (flag) { if (IsUsingMetallic(this.m_Terrain.materialType, this.m_Terrain.materialTemplate)) { EditorGUILayout.Space(); float labelWidth = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = 75f; this.m_Metallic = EditorGUILayout.Slider("Metallic", this.m_Metallic, 0f, 1f, new GUILayoutOption[0]); EditorGUIUtility.labelWidth = labelWidth; } else if (IsUsingSpecular(this.m_Terrain.materialType, this.m_Terrain.materialTemplate)) { this.m_Specular = EditorGUILayout.ColorField("Specular", this.m_Specular, new GUILayoutOption[0]); } if (IsUsingSmoothness(this.m_Terrain.materialType, this.m_Terrain.materialTemplate) && !TextureUtil.HasAlphaTextureFormat(this.m_Texture.format)) { EditorGUILayout.Space(); float num3 = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = 75f; this.m_Smoothness = EditorGUILayout.Slider("Smoothness", this.m_Smoothness, 0f, 1f, new GUILayoutOption[0]); EditorGUIUtility.labelWidth = num3; } } SplatSizeGUI(ref this.m_TileSize, ref this.m_TileOffset); bool flag2 = EditorGUI.EndChangeCheck(); EditorGUILayout.EndScrollView(); GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.FlexibleSpace(); GUI.enabled = flag; GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.MinWidth(100f) }; if (GUILayout.Button(this.m_ButtonTitle, options)) { this.ApplyTerrainSplat(); base.Close(); GUIUtility.ExitGUI(); } GUI.enabled = true; GUILayout.EndHorizontal(); if ((flag2 && flag) && (this.m_Index != -1)) { this.ApplyTerrainSplat(); } }
public void OnPreviewSettings(Object[] targets) { if (!ShaderUtil.hardwareSupportsRectRenderTexture) { return; } GUI.enabled = true; InitPreview(); bool showMode = true; bool alphaOnly = true; //@TODO: Share some code with texture inspector??? bool hasAlpha = false; int mipCount = 8; foreach (Texture t2 in targets) { mipCount = Mathf.Max(mipCount, TextureUtil.GetMipmapCount(t2)); Cubemap cubemap = t2 as Cubemap; if (cubemap) { TextureFormat format = cubemap.format; if (!TextureUtil.IsAlphaOnlyTextureFormat(format)) { alphaOnly = false; } if (TextureUtil.HasAlphaTextureFormat(format)) { TextureUsageMode mode = TextureUtil.GetUsageMode(t2); if (mode == TextureUsageMode.Default) // all other texture usage modes don't displayable alpha { hasAlpha = true; } } } else { hasAlpha = true; alphaOnly = false; } } if (alphaOnly) { m_PreviewType = PreviewType.Alpha; showMode = false; } else if (!hasAlpha) { m_PreviewType = PreviewType.RGB; showMode = false; } if (showMode) { GUIContent[] kPreviewIcons = { Styles.RGBIcon, Styles.alphaIcon }; int index = (int)m_PreviewType; if (GUILayout.Button(kPreviewIcons[index], Styles.preButton)) { m_PreviewType = (PreviewType)(++index % kPreviewIcons.Length); } } GUI.enabled = (mipCount != 1); GUILayout.Box(Styles.smallZoom, Styles.preLabel); GUI.changed = false; m_MipLevel = Mathf.Round(GUILayout.HorizontalSlider(m_MipLevel, mipCount - 1, 0, Styles.preSlider, Styles.preSliderThumb, GUILayout.MaxWidth(64))); GUILayout.Box(Styles.largeZoom, Styles.preLabel); GUI.enabled = true; }
public override void OnPreviewSettings() { if (this.IsCubemap()) { this.m_CubemapPreview.OnPreviewSettings(base.targets); } else { if (TextureInspector.s_Styles == null) { TextureInspector.s_Styles = new TextureInspector.Styles(); } Texture texture = base.target as Texture; bool flag = true; bool flag2 = false; bool flag3 = true; int num = 1; if (base.target is Texture2D || base.target is ProceduralTexture) { flag2 = true; flag3 = false; } UnityEngine.Object[] targets = base.targets; for (int i = 0; i < targets.Length; i++) { Texture texture2 = (Texture)targets[i]; if (!(texture2 == null)) { TextureFormat format = (TextureFormat)0; bool flag4 = false; if (texture2 is Texture2D) { format = (texture2 as Texture2D).format; flag4 = true; } else if (texture2 is ProceduralTexture) { format = (texture2 as ProceduralTexture).format; flag4 = true; } if (flag4) { if (!TextureUtil.IsAlphaOnlyTextureFormat(format)) { flag2 = false; } if (TextureUtil.HasAlphaTextureFormat(format)) { if (TextureUtil.GetUsageMode(texture2) == TextureUsageMode.Default) { flag3 = true; } } } num = Mathf.Max(num, TextureUtil.GetMipmapCount(texture2)); } } if (flag2) { this.m_ShowAlpha = true; flag = false; } else if (!flag3) { this.m_ShowAlpha = false; flag = false; } if (flag && texture != null && !TextureInspector.IsNormalMap(texture)) { this.m_ShowAlpha = GUILayout.Toggle(this.m_ShowAlpha, (!this.m_ShowAlpha) ? TextureInspector.s_Styles.RGBIcon : TextureInspector.s_Styles.alphaIcon, TextureInspector.s_Styles.previewButton, new GUILayoutOption[0]); } GUI.enabled = (num != 1); GUILayout.Box(TextureInspector.s_Styles.smallZoom, TextureInspector.s_Styles.previewLabel, new GUILayoutOption[0]); GUI.changed = false; this.m_MipLevel = Mathf.Round(GUILayout.HorizontalSlider(this.m_MipLevel, (float)(num - 1), 0f, TextureInspector.s_Styles.previewSlider, TextureInspector.s_Styles.previewSliderThumb, new GUILayoutOption[] { GUILayout.MaxWidth(64f) })); GUILayout.Box(TextureInspector.s_Styles.largeZoom, TextureInspector.s_Styles.previewLabel, new GUILayoutOption[0]); GUI.enabled = true; } }
public override void OnPreviewSettings() { if (this.IsCubemap()) { this.m_CubemapPreview.OnPreviewSettings(base.targets); } else { if (s_Styles == null) { s_Styles = new Styles(); } Texture target = base.target as Texture; bool flag = true; bool flag2 = false; bool flag3 = true; int a = 1; if ((base.target is Texture2D) || (base.target is ProceduralTexture)) { flag2 = true; flag3 = false; } foreach (Texture texture2 in base.targets) { TextureFormat format = (TextureFormat)0; bool flag4 = false; if (texture2 is Texture2D) { format = (texture2 as Texture2D).format; flag4 = true; } else if (texture2 is ProceduralTexture) { format = (texture2 as ProceduralTexture).format; flag4 = true; } if (flag4) { if (!TextureUtil.IsAlphaOnlyTextureFormat(format)) { flag2 = false; } if (TextureUtil.HasAlphaTextureFormat(format) && (TextureUtil.GetUsageMode(texture2) == TextureUsageMode.Default)) { flag3 = true; } } a = Mathf.Max(a, TextureUtil.GetMipmapCount(texture2)); } if (flag2) { this.m_ShowAlpha = true; flag = false; } else if (!flag3) { this.m_ShowAlpha = false; flag = false; } if (flag && !IsNormalMap(target)) { this.m_ShowAlpha = GUILayout.Toggle(this.m_ShowAlpha, !this.m_ShowAlpha ? s_Styles.RGBIcon : s_Styles.alphaIcon, s_Styles.previewButton, new GUILayoutOption[0]); } GUI.enabled = a != 1; GUILayout.Box(s_Styles.smallZoom, s_Styles.previewLabel, new GUILayoutOption[0]); GUI.changed = false; GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.MaxWidth(64f) }; this.m_MipLevel = Mathf.Round(GUILayout.HorizontalSlider(this.m_MipLevel, (float)(a - 1), 0f, s_Styles.previewSlider, s_Styles.previewSliderThumb, options)); GUILayout.Box(s_Styles.largeZoom, s_Styles.previewLabel, new GUILayoutOption[0]); GUI.enabled = true; } }
public override void OnPreviewSettings() { if (IsCubemap()) { m_CubemapPreview.OnPreviewSettings(targets); return; } if (IsTexture2DArray() && !SystemInfo.supports2DArrayTextures) { return; } if (s_Styles == null) { s_Styles = new Styles(); } // TextureInspector code is reused for RenderTexture and Cubemap inspectors. // Make sure we can handle the situation where target is just a Texture and // not a Texture2D. It's also used for large popups for mini texture fields, // and while it's being shown the actual texture object might disappear -- // make sure to handle null targets. Texture tex = target as Texture; bool alphaOnly = false; bool hasAlpha = true; int mipCount = 1; if (target is Texture2D) { alphaOnly = true; hasAlpha = false; } foreach (Texture t in targets) { if (t == null) // texture might have disappeared while we're showing this in a preview popup { continue; } TextureFormat format = 0; bool checkFormat = false; if (t is Texture2D) { format = (t as Texture2D).format; checkFormat = true; } if (checkFormat) { if (!TextureUtil.IsAlphaOnlyTextureFormat(format)) { alphaOnly = false; } if (TextureUtil.HasAlphaTextureFormat(format)) { TextureUsageMode mode = TextureUtil.GetUsageMode(t); if (mode == TextureUsageMode.Default) // all other texture usage modes don't displayable alpha { hasAlpha = true; } } } mipCount = Mathf.Max(mipCount, TextureUtil.GetMipmapCount(t)); } List <PreviewMode> previewCandidates = new List <PreviewMode>(5); previewCandidates.Add(PreviewMode.RGB); previewCandidates.Add(PreviewMode.R); previewCandidates.Add(PreviewMode.G); previewCandidates.Add(PreviewMode.B); previewCandidates.Add(PreviewMode.A); if (alphaOnly) { previewCandidates.Clear(); previewCandidates.Add(PreviewMode.A); m_PreviewMode = PreviewMode.A; } else if (!hasAlpha) { previewCandidates.Remove(PreviewMode.A); } if (previewCandidates.Count > 1 && tex != null && !IsNormalMap(tex)) { int selectedIndex = previewCandidates.IndexOf(m_PreviewMode); if (selectedIndex == -1) { selectedIndex = 0; } if (previewCandidates.Contains(PreviewMode.RGB)) { m_PreviewMode = GUILayout.Toggle(m_PreviewMode == PreviewMode.RGB, s_Styles.previewButtonContents[0], s_Styles.toolbarButton) ? PreviewMode.RGB : m_PreviewMode; } if (previewCandidates.Contains(PreviewMode.R)) { m_PreviewMode = GUILayout.Toggle(m_PreviewMode == PreviewMode.R, s_Styles.previewButtonContents[1], s_Styles.toolbarButton) ? PreviewMode.R : m_PreviewMode; } if (previewCandidates.Contains(PreviewMode.G)) { m_PreviewMode = GUILayout.Toggle(m_PreviewMode == PreviewMode.G, s_Styles.previewButtonContents[2], s_Styles.toolbarButton) ? PreviewMode.G : m_PreviewMode; } if (previewCandidates.Contains(PreviewMode.B)) { m_PreviewMode = GUILayout.Toggle(m_PreviewMode == PreviewMode.B, s_Styles.previewButtonContents[3], s_Styles.toolbarButton) ? PreviewMode.B : m_PreviewMode; } if (previewCandidates.Contains(PreviewMode.A)) { m_PreviewMode = GUILayout.Toggle(m_PreviewMode == PreviewMode.A, s_Styles.previewButtonContents[4], s_Styles.toolbarButton) ? PreviewMode.A : m_PreviewMode; } } if (mipCount > 1) { GUILayout.Box(s_Styles.smallZoom, s_Styles.previewLabel); GUI.changed = false; m_MipLevel = Mathf.Round(GUILayout.HorizontalSlider(m_MipLevel, mipCount - 1, 0, s_Styles.previewSlider, s_Styles.previewSliderThumb, GUILayout.MaxWidth(64))); //For now, we don't have mipmaps smaller than the tile size when using VT. if (EditorGUI.UseVTMaterial(tex)) { int numMipsOfTile = (int)Mathf.Log(VirtualTexturing.EditorHelpers.tileSize, 2) + 1; m_MipLevel = Mathf.Min(m_MipLevel, Mathf.Max(mipCount - numMipsOfTile, 0)); } GUILayout.Box(s_Styles.largeZoom, s_Styles.previewLabel); } }
public void OnPreviewSettings(UnityEngine.Object[] targets) { if (ShaderUtil.hardwareSupportsRectRenderTexture) { GUI.enabled = true; this.InitPreview(); bool flag = true; bool flag2 = true; bool flag3 = false; int num = 8; for (int i = 0; i < targets.Length; i++) { Texture texture = (Texture)targets[i]; num = Mathf.Max(num, TextureUtil.GetMipmapCount(texture)); Cubemap cubemap = texture as Cubemap; if (cubemap) { TextureFormat format = cubemap.format; if (!TextureUtil.IsAlphaOnlyTextureFormat(format)) { flag2 = false; } if (TextureUtil.HasAlphaTextureFormat(format)) { if (TextureUtil.GetUsageMode(texture) == TextureUsageMode.Default) { flag3 = true; } } } else { flag3 = true; flag2 = false; } } if (flag2) { this.m_PreviewType = CubemapPreview.PreviewType.Alpha; flag = false; } else if (!flag3) { this.m_PreviewType = CubemapPreview.PreviewType.RGB; flag = false; } if (flag) { GUIContent[] array = new GUIContent[] { CubemapPreview.Styles.RGBIcon, CubemapPreview.Styles.alphaIcon }; int previewType = (int)this.m_PreviewType; if (GUILayout.Button(array[previewType], CubemapPreview.Styles.preButton, new GUILayoutOption[0])) { this.m_PreviewType = (previewType + CubemapPreview.PreviewType.Alpha) % (CubemapPreview.PreviewType)array.Length; } } GUI.enabled = (num != 1); GUILayout.Box(CubemapPreview.Styles.smallZoom, CubemapPreview.Styles.preLabel, new GUILayoutOption[0]); GUI.changed = false; this.m_MipLevel = Mathf.Round(GUILayout.HorizontalSlider(this.m_MipLevel, (float)(num - 1), 0f, CubemapPreview.Styles.preSlider, CubemapPreview.Styles.preSliderThumb, new GUILayoutOption[] { GUILayout.MaxWidth(64f) })); GUILayout.Box(CubemapPreview.Styles.largeZoom, CubemapPreview.Styles.preLabel, new GUILayoutOption[0]); GUI.enabled = true; } }
private void OnGUI() { const float controlSize = 64; EditorGUIUtility.labelWidth = position.width - controlSize - 20; bool isValid = true; m_ScrollPosition = EditorGUILayout.BeginVerticalScrollView(m_ScrollPosition, false, GUI.skin.verticalScrollbar, GUI.skin.scrollView); isValid &= ValidateTerrain(); EditorGUI.BeginChangeCheck(); // texture & normal map GUILayout.BeginHorizontal(); string textureLabel = ""; float alignmentOffset = 0.0f; switch (m_Terrain.materialType) { case Terrain.MaterialType.BuiltInLegacyDiffuse: textureLabel = "\n Diffuse (RGB)"; alignmentOffset = 15.0f; break; case Terrain.MaterialType.BuiltInLegacySpecular: textureLabel = "Diffuse (RGB)\n Gloss (A)"; alignmentOffset = 12.0f; break; case Terrain.MaterialType.BuiltInStandard: textureLabel = " Albedo (RGB)\nSmoothness (A)"; alignmentOffset = 15.0f; break; case Terrain.MaterialType.Custom: textureLabel = " \n Splat"; alignmentOffset = 0.0f; break; } TextureFieldGUI(textureLabel, ref m_Texture, alignmentOffset); Texture2D oldNormalMap = m_NormalMap; TextureFieldGUI("\nNormal", ref m_NormalMap, -4.0f); if (m_NormalMap != oldNormalMap) { CheckIfNormalMapHasCorrectTextureType(); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); isValid &= ValidateTextures(); // PBR text & settings if (isValid) { if (IsUsingMetallic(m_Terrain.materialType, m_Terrain.materialTemplate)) { EditorGUILayout.Space(); float oldLabelWidth = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = 75.0f; m_Metallic = EditorGUILayout.Slider("Metallic", m_Metallic, 0.0f, 1.0f); EditorGUIUtility.labelWidth = oldLabelWidth; } else if (IsUsingSpecular(m_Terrain.materialType, m_Terrain.materialTemplate)) { m_Specular = EditorGUILayout.ColorField("Specular", m_Specular); } if (IsUsingSmoothness(m_Terrain.materialType, m_Terrain.materialTemplate) && !TextureUtil.HasAlphaTextureFormat(m_Texture.format)) { EditorGUILayout.Space(); float oldLabelWidth = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = 75.0f; m_Smoothness = EditorGUILayout.Slider("Smoothness", m_Smoothness, 0.0f, 1.0f); EditorGUIUtility.labelWidth = oldLabelWidth; } } // tiling & offset SplatSizeGUI(ref m_TileSize, ref m_TileOffset); bool modified = EditorGUI.EndChangeCheck(); EditorGUILayout.EndScrollView(); GUILayout.FlexibleSpace(); // button GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUI.enabled = isValid; if (GUILayout.Button(m_ButtonTitle, GUILayout.MinWidth(100))) { ApplyTerrainSplat(); Close(); GUIUtility.ExitGUI(); } GUI.enabled = true; GUILayout.EndHorizontal(); if (modified && isValid && m_Index != -1) { ApplyTerrainSplat(); } }
public override void OnPreviewSettings() { if (this.IsCubemap()) { this.m_CubemapPreview.OnPreviewSettings(this.targets); } else { if (TextureInspector.s_Styles == null) { TextureInspector.s_Styles = new TextureInspector.Styles(); } Texture target1 = this.target as Texture; bool flag1 = true; bool flag2 = false; bool flag3 = true; int a = 1; if (this.target is Texture2D || this.target is ProceduralTexture) { flag2 = true; flag3 = false; } foreach (Texture target2 in this.targets) { TextureFormat format = (TextureFormat)0; bool flag4 = false; if (target2 is Texture2D) { format = (target2 as Texture2D).format; flag4 = true; } else if (target2 is ProceduralTexture) { format = (target2 as ProceduralTexture).format; flag4 = true; } if (flag4) { if (!TextureUtil.IsAlphaOnlyTextureFormat(format)) { flag2 = false; } if (TextureUtil.HasAlphaTextureFormat(format) && TextureUtil.GetUsageMode(target2) == TextureUsageMode.Default) { flag3 = true; } } a = Mathf.Max(a, TextureUtil.CountMipmaps(target2)); } if (flag2) { this.m_ShowAlpha = true; flag1 = false; } else if (!flag3) { this.m_ShowAlpha = false; flag1 = false; } if (flag1 && !TextureInspector.IsNormalMap(target1)) { this.m_ShowAlpha = GUILayout.Toggle(this.m_ShowAlpha, !this.m_ShowAlpha ? TextureInspector.s_Styles.RGBIcon : TextureInspector.s_Styles.alphaIcon, TextureInspector.s_Styles.previewButton, new GUILayoutOption[0]); } GUI.enabled = a != 1; GUILayout.Box(TextureInspector.s_Styles.smallZoom, TextureInspector.s_Styles.previewLabel, new GUILayoutOption[0]); GUI.changed = false; this.m_MipLevel = Mathf.Round(GUILayout.HorizontalSlider(this.m_MipLevel, (float)(a - 1), 0.0f, TextureInspector.s_Styles.previewSlider, TextureInspector.s_Styles.previewSliderThumb, GUILayout.MaxWidth(64f))); GUILayout.Box(TextureInspector.s_Styles.largeZoom, TextureInspector.s_Styles.previewLabel, new GUILayoutOption[0]); GUI.enabled = true; } }
public override void OnPreviewSettings() { if (IsCubemap()) { m_CubemapPreview.OnPreviewSettings(targets); return; } if (s_Styles == null) { s_Styles = new Styles(); } // TextureInspector code is reused for RenderTexture and Cubemap inspectors. // Make sure we can handle the situation where target is just a Texture and // not a Texture2D. It's also used for large popups for mini texture fields, // and while it's being shown the actual texture object might disappear -- // make sure to handle null targets. Texture tex = target as Texture; bool showMode = true; bool alphaOnly = false; bool hasAlpha = true; int mipCount = 1; if (target is Texture2D) { alphaOnly = true; hasAlpha = false; } foreach (Texture t in targets) { if (t == null) // texture might have disappeared while we're showing this in a preview popup { continue; } TextureFormat format = 0; bool checkFormat = false; if (t is Texture2D) { format = (t as Texture2D).format; checkFormat = true; } if (checkFormat) { if (!TextureUtil.IsAlphaOnlyTextureFormat(format)) { alphaOnly = false; } if (TextureUtil.HasAlphaTextureFormat(format)) { TextureUsageMode mode = TextureUtil.GetUsageMode(t); if (mode == TextureUsageMode.Default) // all other texture usage modes don't displayable alpha { hasAlpha = true; } } } mipCount = Mathf.Max(mipCount, TextureUtil.GetMipmapCount(t)); } if (alphaOnly) { m_ShowAlpha = true; showMode = false; } else if (!hasAlpha) { m_ShowAlpha = false; showMode = false; } if (showMode && tex != null && !IsNormalMap(tex)) { m_ShowAlpha = GUILayout.Toggle(m_ShowAlpha, m_ShowAlpha ? s_Styles.alphaIcon : s_Styles.RGBIcon, s_Styles.previewButton); } if (mipCount > 1) { GUILayout.Box(s_Styles.smallZoom, s_Styles.previewLabel); GUI.changed = false; m_MipLevel = Mathf.Round(GUILayout.HorizontalSlider(m_MipLevel, mipCount - 1, 0, s_Styles.previewSlider, s_Styles.previewSliderThumb, GUILayout.MaxWidth(64))); GUILayout.Box(s_Styles.largeZoom, s_Styles.previewLabel); } }
public void OnPreviewSettings(Object[] targets) { if (!ShaderUtil.hardwareSupportsRectRenderTexture) { return; } GUI.enabled = true; this.InitPreview(); bool flag1 = true; bool flag2 = true; bool flag3 = false; int a = 8; foreach (Texture target in targets) { a = Mathf.Max(a, TextureUtil.CountMipmaps(target)); Cubemap cubemap = target as Cubemap; if ((bool)((Object)cubemap)) { TextureFormat format = cubemap.format; if (!TextureUtil.IsAlphaOnlyTextureFormat(format)) { flag2 = false; } if (TextureUtil.HasAlphaTextureFormat(format) && TextureUtil.GetUsageMode(target) == TextureUsageMode.Default) { flag3 = true; } } else { flag3 = true; flag2 = false; } } if (flag2) { this.m_PreviewType = CubemapPreview.PreviewType.Alpha; flag1 = false; } else if (!flag3) { this.m_PreviewType = CubemapPreview.PreviewType.RGB; flag1 = false; } if (flag1) { GUIContent[] guiContentArray = new GUIContent[2] { CubemapPreview.Styles.RGBIcon, CubemapPreview.Styles.alphaIcon }; int previewType = (int)this.m_PreviewType; if (GUILayout.Button(guiContentArray[previewType], CubemapPreview.Styles.preButton, new GUILayoutOption[0])) { int num; this.m_PreviewType = (CubemapPreview.PreviewType)((num = previewType + 1) % guiContentArray.Length); } } GUI.enabled = a != 1; GUILayout.Box(CubemapPreview.Styles.smallZoom, CubemapPreview.Styles.preLabel, new GUILayoutOption[0]); GUI.changed = false; this.m_MipLevel = Mathf.Round(GUILayout.HorizontalSlider(this.m_MipLevel, (float)(a - 1), 0.0f, CubemapPreview.Styles.preSlider, CubemapPreview.Styles.preSliderThumb, GUILayout.MaxWidth(64f))); GUILayout.Box(CubemapPreview.Styles.largeZoom, CubemapPreview.Styles.preLabel, new GUILayoutOption[0]); GUI.enabled = true; }