Esempio n. 1
0
 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.CountMipmaps(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;
     }
 }
Esempio n. 2
0
        public override void OnInspectorGUI()
        {
            if (this.m_Images == null)
            {
                this.InitTexturesFromCubemap();
            }
            EditorGUIUtility.labelWidth = 50f;
            Cubemap cubemap = this.target as Cubemap;

            if (cubemap == null)
            {
                return;
            }
            GUILayout.BeginVertical(new GUILayoutOption[0]);
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            this.ShowFace("Right\n(+X)", CubemapFace.PositiveX);
            this.ShowFace("Left\n(-X)", CubemapFace.NegativeX);
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            this.ShowFace("Top\n(+Y)", CubemapFace.PositiveY);
            this.ShowFace("Bottom\n(-Y)", CubemapFace.NegativeY);
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            this.ShowFace("Front\n(+Z)", CubemapFace.PositiveZ);
            this.ShowFace("Back\n(-Z)", CubemapFace.NegativeZ);
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
            EditorGUIUtility.labelWidth = 0f;
            EditorGUILayout.Space();
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.HelpBox("Lowering face size is a destructive operation, you might need to re-assign the textures later to fix resolution issues. It's preferable to use Cubemap texture import type instead of Legacy Cubemap assets.", MessageType.Warning);
            int num = TextureUtil.GetGLWidth(cubemap);

            num = EditorGUILayout.IntPopup("Face size", num, CubemapInspector.kSizes, CubemapInspector.kSizesValues, new GUILayoutOption[0]);
            int  num2      = TextureUtil.CountMipmaps(cubemap);
            bool useMipmap = EditorGUILayout.Toggle("MipMaps", num2 > 1, new GUILayoutOption[0]);
            bool flag      = TextureUtil.GetLinearSampled(cubemap);

            flag = EditorGUILayout.Toggle("Linear", flag, new GUILayoutOption[0]);
            bool flag2 = TextureUtil.IsCubemapReadable(cubemap);

            flag2 = EditorGUILayout.Toggle("Readable", flag2, new GUILayoutOption[0]);
            if (EditorGUI.EndChangeCheck())
            {
                if (TextureUtil.ReformatCubemap(ref cubemap, num, num, cubemap.format, useMipmap, flag))
                {
                    this.InitTexturesFromCubemap();
                }
                TextureUtil.MarkCubemapReadable(cubemap, flag2);
                cubemap.Apply();
            }
        }
        protected void DrawTexture()
        {
            int   num        = Mathf.Max(this.m_Texture.width, 1);
            float num2       = Mathf.Min(this.m_MipLevel, (float)(TextureUtil.CountMipmaps(this.m_Texture) - 1));
            float mipMapBias = this.m_Texture.mipMapBias;

            TextureUtil.SetMipMapBiasNoDirty(this.m_Texture, num2 - this.Log2((float)num / this.m_TextureRect.width));
            FilterMode filterMode = this.m_Texture.filterMode;

            TextureUtil.SetFilterModeNoDirty(this.m_Texture, FilterMode.Point);
            if (this.m_ShowAlpha)
            {
                EditorGUI.DrawTextureAlpha(this.m_TextureRect, this.m_Texture);
            }
            else
            {
                EditorGUI.DrawTextureTransparent(this.m_TextureRect, this.m_Texture);
            }
            TextureUtil.SetMipMapBiasNoDirty(this.m_Texture, mipMapBias);
            TextureUtil.SetFilterModeNoDirty(this.m_Texture, filterMode);
        }
Esempio n. 4
0
        protected void DoAlphaZoomToolbarGUI()
        {
            this.m_ShowAlpha = GUILayout.Toggle(this.m_ShowAlpha, (!this.m_ShowAlpha) ? SpriteUtilityWindow.s_Styles.RGBIcon : SpriteUtilityWindow.s_Styles.alphaIcon, "toolbarButton", new GUILayoutOption[0]);
            this.m_Zoom      = GUILayout.HorizontalSlider(this.m_Zoom, this.GetMinZoom(), 50f, SpriteUtilityWindow.s_Styles.preSlider, SpriteUtilityWindow.s_Styles.preSliderThumb, new GUILayoutOption[]
            {
                GUILayout.MaxWidth(64f)
            });
            int num = 1;

            if (this.m_Texture != null)
            {
                num = Mathf.Max(num, TextureUtil.CountMipmaps(this.m_Texture));
            }
            EditorGUI.BeginDisabledGroup(num == 1);
            GUILayout.Box(SpriteUtilityWindow.s_Styles.smallMip, SpriteUtilityWindow.s_Styles.preLabel, new GUILayoutOption[0]);
            this.m_MipLevel = Mathf.Round(GUILayout.HorizontalSlider(this.m_MipLevel, (float)(num - 1), 0f, SpriteUtilityWindow.s_Styles.preSlider, SpriteUtilityWindow.s_Styles.preSliderThumb, new GUILayoutOption[]
            {
                GUILayout.MaxWidth(64f)
            }));
            GUILayout.Box(SpriteUtilityWindow.s_Styles.largeMip, SpriteUtilityWindow.s_Styles.preLabel, new GUILayoutOption[0]);
            EditorGUI.EndDisabledGroup();
        }
Esempio n. 5
0
 public float GetMipLevelForRendering(Texture texture)
 {
     return(Mathf.Min(this.m_MipLevel, (float)TextureUtil.CountMipmaps(texture)));
 }
Esempio n. 6
0
        public void OnPreviewSettings(UnityEngine.Object[] targets)
        {
            if (!ShaderUtil.hardwareSupportsRectRenderTexture)
            {
                return;
            }
            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.CountMipmaps(texture));
                Cubemap cubemap = texture as Cubemap;
                if (cubemap)
                {
                    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 = CubemapPreview.PreviewType.Alpha;
                flag = false;
            }
            else
            {
                if (!flag3)
                {
                    this.m_PreviewType = CubemapPreview.PreviewType.RGB;
                    flag = false;
                }
            }
            if (flag)
            {
                GUIContent[] array = new GUIContent[]
                {
                    CubemapPreview.s_RGBIcon,
                    CubemapPreview.s_AlphaIcon
                };
                int previewType = (int)this.m_PreviewType;
                if (GUILayout.Button(array[previewType], CubemapPreview.s_PreButton, new GUILayoutOption[0]))
                {
                    this.m_PreviewType = (previewType + CubemapPreview.PreviewType.Alpha) % (CubemapPreview.PreviewType)array.Length;
                }
            }
            GUI.enabled = (num != 1);
            GUILayout.Box(CubemapPreview.s_SmallZoom, CubemapPreview.s_PreLabel, new GUILayoutOption[0]);
            GUI.changed     = false;
            this.m_MipLevel = Mathf.Round(GUILayout.HorizontalSlider(this.m_MipLevel, (float)(num - 1), 0f, CubemapPreview.s_PreSlider, CubemapPreview.s_PreSliderThumb, new GUILayoutOption[]
            {
                GUILayout.MaxWidth(64f)
            }));
            GUILayout.Box(CubemapPreview.s_LargeZoom, CubemapPreview.s_PreLabel, new GUILayoutOption[0]);
            GUI.enabled = true;
        }
Esempio n. 7
0
        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;
        }