DoesSourceTextureHaveAlpha() private method

private DoesSourceTextureHaveAlpha ( ) : bool
return bool
        /**
         * Does two things:
         * 1 - Changes the NPOT strategy to "ToNearest";
         * 2 - Changes the compression to DXT1 or DXT5 if compression is set to something different than DTX1.
         * It only changes the meta file of the texture.
         */
        static void DxtCompressTexture(TextureImporter textureImporter)
        {
            TextureImporterFormat format;
            TextureImporterSettings textureImporterSettings = new TextureImporterSettings();
            textureImporter.ReadTextureSettings(textureImporterSettings);
            format = textureImporterSettings.textureFormat;

            if (format != TextureImporterFormat.DXT1)
            {
                if (textureImporter.DoesSourceTextureHaveAlpha())
                    format = TextureImporterFormat.DXT5;
                else
                    format = TextureImporterFormat.DXT1;
            }

            textureImporter.npotScale = TextureImporterNPOTScale.ToNearest;

            textureImporterSettings.textureFormat = format;
            textureImporter.SetTextureSettings(textureImporterSettings);
        }
        public void Sync()
        {
            // Use settings from default if any of the targets are not overridden
            if (!isDefault && (!overridden || m_OverriddenIsDifferent))
            {
                TextureImportPlatformSettings defaultSettings = m_Inspector.m_PlatformSettings[0];
                m_PlatformSettings.maxTextureSize       = defaultSettings.maxTextureSize;
                m_MaxTextureSizeIsDifferent             = defaultSettings.m_MaxTextureSizeIsDifferent;
                m_PlatformSettings.resizeAlgorithm      = defaultSettings.resizeAlgorithm;
                m_ResizeAlgorithmIsDifferent            = defaultSettings.m_ResizeAlgorithmIsDifferent;
                m_PlatformSettings.textureCompression   = defaultSettings.textureCompression;
                m_TextureCompressionIsDifferent         = defaultSettings.m_TextureCompressionIsDifferent;
                m_PlatformSettings.format               = defaultSettings.format;
                m_TextureFormatIsDifferent              = defaultSettings.m_TextureFormatIsDifferent;
                m_PlatformSettings.compressionQuality   = defaultSettings.compressionQuality;
                m_CompressionQualityIsDifferent         = defaultSettings.m_CompressionQualityIsDifferent;
                m_PlatformSettings.crunchedCompression  = defaultSettings.crunchedCompression;
                m_CrunchedCompressionIsDifferent        = defaultSettings.m_CrunchedCompressionIsDifferent;
                m_PlatformSettings.allowsAlphaSplitting = defaultSettings.allowsAlphaSplitting;
                m_AlphaSplitIsDifferent = defaultSettings.m_AlphaSplitIsDifferent;
                m_AndroidETC2FallbackOverrideIsDifferent = defaultSettings.m_AndroidETC2FallbackOverrideIsDifferent;
            }

            if ((overridden || m_OverriddenIsDifferent) && m_PlatformSettings.format < 0)
            {
                var showSettingsForPreset = m_Inspector.assetTarget == null;

                m_PlatformSettings.format = TextureImporter.DefaultFormatFromTextureParameters(
                    GetSettings(importers[0]),
                    m_PlatformSettings,
                    showSettingsForPreset || importers[0].DoesSourceTextureHaveAlpha(),
                    showSettingsForPreset || importers[0].IsSourceTextureHDR(),
                    m_Target
                    );
                m_TextureFormatIsDifferent = false;

                for (int i = 1; i < importers.Length; i++)
                {
                    TextureImporter         imp      = importers[i];
                    TextureImporterSettings settings = GetSettings(imp);

                    TextureImporterFormat format = TextureImporter.DefaultFormatFromTextureParameters(settings,
                                                                                                      m_PlatformSettings,
                                                                                                      showSettingsForPreset || imp.DoesSourceTextureHaveAlpha(),
                                                                                                      showSettingsForPreset || imp.IsSourceTextureHDR(),
                                                                                                      m_Target
                                                                                                      );
                    if (format != m_PlatformSettings.format)
                    {
                        m_TextureFormatIsDifferent = true;
                    }
                }
            }
        }
        public void Sync()
        {
            if (!this.isDefault && (!this.m_Overridden || this.m_OverriddenIsDifferent))
            {
                TextureImportPlatformSettings textureImportPlatformSettings = this.m_Inspector.m_PlatformSettings[0];
                this.m_MaxTextureSize                = textureImportPlatformSettings.m_MaxTextureSize;
                this.m_MaxTextureSizeIsDifferent     = textureImportPlatformSettings.m_MaxTextureSizeIsDifferent;
                this.m_TextureFormatArray            = (TextureImporterFormat[])textureImportPlatformSettings.m_TextureFormatArray.Clone();
                this.m_TextureFormatIsDifferent      = textureImportPlatformSettings.m_TextureFormatIsDifferent;
                this.m_CompressionQuality            = textureImportPlatformSettings.m_CompressionQuality;
                this.m_CompressionQualityIsDifferent = textureImportPlatformSettings.m_CompressionQualityIsDifferent;
            }
            TextureImporterType textureType = this.m_Inspector.textureType;
            int i = 0;

            while (i < this.importers.Length)
            {
                TextureImporter         textureImporter = this.importers[i];
                TextureImporterSettings settings        = this.GetSettings(textureImporter);
                if (textureType == TextureImporterType.Advanced)
                {
                    if (!this.isDefault)
                    {
                        if (!this.SupportsFormat(this.m_TextureFormatArray[i], textureImporter))
                        {
                            this.m_TextureFormatArray[i] = TextureImporter.FullToSimpleTextureFormat(this.m_TextureFormatArray[i]);
                        }
                        if (this.m_TextureFormatArray[i] < (TextureImporterFormat)0)
                        {
                            this.m_TextureFormatArray[i] = TextureImporter.SimpleToFullTextureFormat2(this.m_TextureFormatArray[i], textureType, settings, textureImporter.DoesSourceTextureHaveAlpha(), textureImporter.IsSourceTextureHDR(), this.m_Target);
                        }
                        goto IL_14A;
                    }
                }
                else
                {
                    if (this.m_TextureFormatArray[i] >= (TextureImporterFormat)0)
                    {
                        this.m_TextureFormatArray[i] = TextureImporter.FullToSimpleTextureFormat(this.m_TextureFormatArray[i]);
                        goto IL_14A;
                    }
                    goto IL_14A;
                }
IL_17B:
                i++;
                continue;
IL_14A:
                if (settings.normalMap && !TextureImporterInspector.IsGLESMobileTargetPlatform(this.m_Target))
                {
                    this.m_TextureFormatArray[i] = TextureImporterInspector.MakeTextureFormatHaveAlpha(this.m_TextureFormatArray[i]);
                    goto IL_17B;
                }
                goto IL_17B;
            }
            this.m_TextureFormatIsDifferent = false;
            TextureImporterFormat[] textureFormatArray = this.m_TextureFormatArray;
            for (int j = 0; j < textureFormatArray.Length; j++)
            {
                TextureImporterFormat textureImporterFormat = textureFormatArray[j];
                if (textureImporterFormat != this.m_TextureFormatArray[0])
                {
                    this.m_TextureFormatIsDifferent = true;
                }
            }
        }
示例#4
0
 public void Sync()
 {
     if (!this.isDefault && (!this.overridden || this.m_OverriddenIsDifferent))
     {
         TextureImportPlatformSettings textureImportPlatformSettings = this.m_Inspector.m_PlatformSettings[0];
         this.m_PlatformSettings.maxTextureSize       = textureImportPlatformSettings.maxTextureSize;
         this.m_MaxTextureSizeIsDifferent             = textureImportPlatformSettings.m_MaxTextureSizeIsDifferent;
         this.m_PlatformSettings.resizeAlgorithm      = textureImportPlatformSettings.resizeAlgorithm;
         this.m_ResizeAlgorithmIsDifferent            = textureImportPlatformSettings.m_ResizeAlgorithmIsDifferent;
         this.m_PlatformSettings.textureCompression   = textureImportPlatformSettings.textureCompression;
         this.m_TextureCompressionIsDifferent         = textureImportPlatformSettings.m_TextureCompressionIsDifferent;
         this.m_PlatformSettings.format               = textureImportPlatformSettings.format;
         this.m_TextureFormatIsDifferent              = textureImportPlatformSettings.m_TextureFormatIsDifferent;
         this.m_PlatformSettings.compressionQuality   = textureImportPlatformSettings.compressionQuality;
         this.m_CompressionQualityIsDifferent         = textureImportPlatformSettings.m_CompressionQualityIsDifferent;
         this.m_PlatformSettings.crunchedCompression  = textureImportPlatformSettings.crunchedCompression;
         this.m_CrunchedCompressionIsDifferent        = textureImportPlatformSettings.m_CrunchedCompressionIsDifferent;
         this.m_PlatformSettings.allowsAlphaSplitting = textureImportPlatformSettings.allowsAlphaSplitting;
         this.m_AlphaSplitIsDifferent = textureImportPlatformSettings.m_AlphaSplitIsDifferent;
         this.m_AndroidETC2FallbackOverrideIsDifferent = textureImportPlatformSettings.m_AndroidETC2FallbackOverrideIsDifferent;
     }
     if ((this.overridden || this.m_OverriddenIsDifferent) && this.m_PlatformSettings.format < (TextureImporterFormat)0)
     {
         this.m_PlatformSettings.format  = TextureImporter.FormatFromTextureParameters(this.GetSettings(this.importers[0]), this.m_PlatformSettings, this.importers[0].DoesSourceTextureHaveAlpha(), this.importers[0].IsSourceTextureHDR(), this.m_Target);
         this.m_TextureFormatIsDifferent = false;
         for (int i = 1; i < this.importers.Length; i++)
         {
             TextureImporter         textureImporter       = this.importers[i];
             TextureImporterSettings settings              = this.GetSettings(textureImporter);
             TextureImporterFormat   textureImporterFormat = TextureImporter.FormatFromTextureParameters(settings, this.m_PlatformSettings, textureImporter.DoesSourceTextureHaveAlpha(), textureImporter.IsSourceTextureHDR(), this.m_Target);
             if (textureImporterFormat != this.m_PlatformSettings.format)
             {
                 this.m_TextureFormatIsDifferent = true;
             }
         }
     }
 }