UnityEngine.Texture2D.Compress C# (CSharp) Method

Compress() public method

Compress texture into DXT format.

public Compress ( bool highQuality ) : void
highQuality bool
return void
        public void Compress(bool highQuality)
        {
            INTERNAL_CALL_Compress(this, highQuality);
        }

Usage Example

コード例 #1
0
        private static void ModifyTexture(this Material material, string propertyName, Texture2D newTexture)
        {
            var currentTexture = material.GetTexture(propertyName) as Texture2D;

            if (currentTexture == null)
            {
                return;
            }

            var needCompression = currentTexture.format == TextureFormat.DXT1 ||
                                  currentTexture.format == TextureFormat.DXT5;

            if (!needCompression)
            {
                needCompression = newTexture.format != TextureFormat.DXT1 &&
                                  newTexture.format != TextureFormat.DXT5;
            }

            if (needCompression)
            {
                newTexture.Compress(false);
            }

            material.SetTexture(propertyName, newTexture);
        }
All Usage Examples Of UnityEngine.Texture2D::Compress