public bool HandleDefaultSettings(List <TextureImporterPlatformSettings> platformSettings, ITexturePlatformSettingsView view, ITexturePlatformSettingsFormatHelper formatHelper)
        {
            Assert.IsTrue(platformSettings.Count > 0, "At least 1 platform setting is needed to display the texture platform setting UI.");

            var allSize                   = platformSettings[0].maxTextureSize;
            var allFormat                 = platformSettings[0].format;
            var allCompression            = platformSettings[0].textureCompression;
            var allUseCrunchedCompression = platformSettings[0].crunchedCompression;
            var allCompressionQuality     = platformSettings[0].compressionQuality;

            var mixedSize                   = false;
            var mixedFormat                 = false;
            var mixedCompression            = false;
            var mixedUseCrunchedCompression = false;
            var mixedCompressionQuality     = false;

            var sizeChanged                   = false;
            var formatChanged                 = false;
            var compressionChanged            = false;
            var useCrunchedCompressionChanged = false;
            var compressionQualityChanged     = false;

            for (var i = 1; i < platformSettings.Count; ++i)
            {
                var settings = platformSettings[i];
                if (settings.maxTextureSize != allSize)
                {
                    mixedSize = true;
                }
                if (settings.format != allFormat)
                {
                    mixedFormat = true;
                }
                if (settings.textureCompression != allCompression)
                {
                    mixedCompression = true;
                }
                if (settings.crunchedCompression != allUseCrunchedCompression)
                {
                    mixedUseCrunchedCompression = true;
                }
                if (settings.compressionQuality != allCompressionQuality)
                {
                    mixedCompressionQuality = true;
                }
            }

            allSize = view.DrawMaxSize(allSize, mixedSize, false, out sizeChanged);

            int[]    formatValues  = null;
            string[] formatStrings = null;
            formatHelper.AcquireDefaultTextureFormatValuesAndStrings(out formatValues, out formatStrings);

            allFormat = view.DrawFormat(allFormat, formatValues, formatStrings, mixedFormat, false, out formatChanged);

            if (allFormat == TextureImporterFormat.Automatic && (!mixedFormat || formatChanged))
            {
                allCompression = view.DrawCompression(allCompression, mixedCompression, false, out compressionChanged);

                if (allCompression != TextureImporterCompression.Uncompressed && (!mixedCompression || compressionChanged))
                {
                    allUseCrunchedCompression = view.DrawUseCrunchedCompression(allUseCrunchedCompression,
                                                                                mixedUseCrunchedCompression, false, out useCrunchedCompressionChanged);

                    if (allUseCrunchedCompression && (!mixedUseCrunchedCompression || useCrunchedCompressionChanged))
                    {
                        allCompressionQuality = view.DrawCompressionQualitySlider(allCompressionQuality,
                                                                                  mixedCompressionQuality, false, out compressionQualityChanged);
                    }
                }
            }

            if (sizeChanged || compressionChanged || formatChanged || useCrunchedCompressionChanged || compressionQualityChanged)
            {
                for (var i = 0; i < platformSettings.Count; ++i)
                {
                    if (sizeChanged)
                    {
                        platformSettings[i].maxTextureSize = allSize;
                    }
                    if (formatChanged)
                    {
                        platformSettings[i].format = allFormat;
                    }
                    if (compressionChanged)
                    {
                        platformSettings[i].textureCompression = allCompression;
                    }
                    if (useCrunchedCompressionChanged)
                    {
                        platformSettings[i].crunchedCompression = allUseCrunchedCompression;
                    }
                    if (compressionQualityChanged)
                    {
                        platformSettings[i].compressionQuality = allCompressionQuality;
                    }
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public bool HandlePlatformSettings(BuildTarget buildTarget, List <TextureImporterPlatformSettings> platformSettings, ITexturePlatformSettingsView view, ITexturePlatformSettingsFormatHelper formatHelper)
        {
            Assert.IsTrue(platformSettings.Count > 0, "At least 1 platform setting is needed to display the texture platform setting UI.");

            var allOverride           = platformSettings[0].overridden;
            var allSize               = platformSettings[0].maxTextureSize;
            var allFormat             = platformSettings[0].format;
            var allCompressionQuality = platformSettings[0].compressionQuality;
            var allAlphaSplit         = platformSettings[0].allowsAlphaSplitting;

            var mixedOverride    = false;
            var mixedSize        = false;
            var mixedFormat      = false;
            var mixedCompression = false;
            var mixedAlphaSplit  = false;

            var overrideChanged    = false;
            var sizeChanged        = false;
            var formatChanged      = false;
            var compressionChanged = false;
            var alphaSplitChanged  = false;

            for (var i = 1; i < platformSettings.Count; ++i)
            {
                var settings = platformSettings[i];
                if (settings.overridden != allOverride)
                {
                    mixedOverride = true;
                }
                if (settings.maxTextureSize != allSize)
                {
                    mixedSize = true;
                }
                if (settings.format != allFormat)
                {
                    mixedFormat = true;
                }
                if (settings.compressionQuality != allCompressionQuality)
                {
                    mixedCompression = true;
                }
                if (settings.allowsAlphaSplitting != allAlphaSplit)
                {
                    mixedAlphaSplit = true;
                }
            }

            allOverride = view.DrawOverride(allOverride, mixedOverride, out overrideChanged);

            allSize = view.DrawMaxSize(allSize, mixedSize, mixedOverride || !allOverride, out sizeChanged);

            int[]    formatValues  = null;
            string[] formatStrings = null;

            formatHelper.AcquireTextureFormatValuesAndStrings(buildTarget, out formatValues, out formatStrings);

            allFormat = view.DrawFormat(allFormat, formatValues, formatStrings, mixedFormat, mixedOverride || !allOverride, out formatChanged);

            if (!mixedFormat && formatHelper.TextureFormatRequireCompressionQualityInput(allFormat))
            {
                bool showAsEnum = BuildTargetDiscovery.PlatformHasFlag(buildTarget, TargetAttributes.HasIntegratedGPU);

                if (showAsEnum)
                {
                    var compressionMode = 1;
                    if (allCompressionQuality == (int)TextureCompressionQuality.Fast)
                    {
                        compressionMode = 0;
                    }
                    else if (allCompressionQuality == (int)TextureCompressionQuality.Best)
                    {
                        compressionMode = 2;
                    }

                    compressionMode = view.DrawCompressionQualityPopup(compressionMode, mixedCompression, mixedOverride || !allOverride, out compressionChanged);

                    if (compressionChanged)
                    {
                        switch (compressionMode)
                        {
                        case 0: allCompressionQuality = (int)TextureCompressionQuality.Fast; break;

                        case 1: allCompressionQuality = (int)TextureCompressionQuality.Normal; break;

                        case 2: allCompressionQuality = (int)TextureCompressionQuality.Best; break;

                        default:
                            Assert.IsTrue(false, "ITexturePlatformSettingsView.DrawCompressionQualityPopup should never return compression option value that's not 0, 1 or 2.");
                            break;
                        }
                    }
                }
                else
                {
                    allCompressionQuality = view.DrawCompressionQualitySlider(allCompressionQuality, mixedCompression, mixedOverride || !allOverride, out compressionChanged);
                }

                // show the ETC1 split option only for sprites on platforms supporting ETC.
                bool isETCPlatform       = TextureImporter.IsETC1SupportedByBuildTarget(buildTarget);
                bool isETCFormatSelected = TextureImporter.IsTextureFormatETC1Compression((TextureFormat)allFormat);
                if (isETCPlatform && isETCFormatSelected)
                {
                    allAlphaSplit = view.DrawAlphaSplit(allAlphaSplit, mixedAlphaSplit, mixedOverride || !allOverride, out alphaSplitChanged);
                }
            }

            if (overrideChanged || sizeChanged || formatChanged || compressionChanged || alphaSplitChanged)
            {
                for (var i = 0; i < platformSettings.Count; ++i)
                {
                    if (overrideChanged)
                    {
                        platformSettings[i].overridden = allOverride;
                    }
                    if (sizeChanged)
                    {
                        platformSettings[i].maxTextureSize = allSize;
                    }
                    if (formatChanged)
                    {
                        platformSettings[i].format = allFormat;
                    }
                    if (compressionChanged)
                    {
                        platformSettings[i].compressionQuality = allCompressionQuality;
                    }
                    if (alphaSplitChanged)
                    {
                        platformSettings[i].allowsAlphaSplitting = allAlphaSplit;
                    }
                }

                return(true);
            }
            else
            {
                return(false);
            }
        }
        public bool HandlePlatformSettings(BuildTarget buildTarget, List <TextureImporterPlatformSettings> platformSettings, ITexturePlatformSettingsView view, ITexturePlatformSettingsFormatHelper formatHelper)
        {
            bool overridden              = platformSettings[0].overridden;
            int  maxTextureSize          = platformSettings[0].maxTextureSize;
            TextureImporterFormat format = platformSettings[0].format;
            int  compressionQuality      = platformSettings[0].compressionQuality;
            int  maxTextureSize2         = maxTextureSize;
            int  compressionQuality2     = compressionQuality;
            bool flag          = false;
            bool isMixedValue  = false;
            bool flag2         = false;
            bool isMixedValue2 = false;
            bool flag3         = false;
            bool flag4         = false;
            bool flag5         = false;
            bool flag6         = false;

            for (int i = 1; i < platformSettings.Count; i++)
            {
                TextureImporterPlatformSettings textureImporterPlatformSettings = platformSettings[i];
                if (textureImporterPlatformSettings.overridden != overridden)
                {
                    flag = true;
                }
                if (textureImporterPlatformSettings.maxTextureSize != maxTextureSize)
                {
                    isMixedValue = true;
                }
                if (textureImporterPlatformSettings.format != format)
                {
                    flag2 = true;
                }
                if (textureImporterPlatformSettings.compressionQuality != compressionQuality)
                {
                    isMixedValue2 = true;
                }
            }
            bool overridden2 = view.DrawOverride(overridden, flag, out flag3);

            if (!flag && overridden)
            {
                maxTextureSize2 = view.DrawMaxSize(maxTextureSize, isMixedValue, out flag4);
            }
            int[]    displayValues  = null;
            string[] displayStrings = null;
            formatHelper.AcquireTextureFormatValuesAndStrings(buildTarget, out displayValues, out displayStrings);
            TextureImporterFormat format2 = view.DrawFormat(format, displayValues, displayStrings, flag2, flag || !overridden, out flag5);

            if (!flag2 && !flag && overridden && formatHelper.TextureFormatRequireCompressionQualityInput(format))
            {
                bool flag7 = buildTarget == BuildTarget.iOS || buildTarget == BuildTarget.tvOS || buildTarget == BuildTarget.Android || buildTarget == BuildTarget.Tizen;
                if (flag7)
                {
                    int defaultValue = 1;
                    if (compressionQuality == 0)
                    {
                        defaultValue = 0;
                    }
                    else if (compressionQuality == 100)
                    {
                        defaultValue = 2;
                    }
                    int num = view.DrawCompressionQualityPopup(defaultValue, isMixedValue2, out flag6);
                    if (flag6)
                    {
                        switch (num)
                        {
                        case 0:
                            compressionQuality2 = 0;
                            break;

                        case 1:
                            compressionQuality2 = 50;
                            break;

                        case 2:
                            compressionQuality2 = 100;
                            break;
                        }
                    }
                }
                else
                {
                    compressionQuality2 = view.DrawCompressionQualitySlider(compressionQuality, isMixedValue2, out flag6);
                }
            }
            bool result;

            if (flag3 || flag4 || flag5 || flag6)
            {
                for (int j = 0; j < platformSettings.Count; j++)
                {
                    if (flag3)
                    {
                        platformSettings[j].overridden = overridden2;
                    }
                    if (flag4)
                    {
                        platformSettings[j].maxTextureSize = maxTextureSize2;
                    }
                    if (flag5)
                    {
                        platformSettings[j].format = format2;
                    }
                    if (flag6)
                    {
                        platformSettings[j].compressionQuality = compressionQuality2;
                    }
                }
                result = true;
            }
            else
            {
                result = false;
            }
            return(result);
        }
        public bool HandleDefaultSettings(List <TextureImporterPlatformSettings> platformSettings, ITexturePlatformSettingsView view)
        {
            int maxTextureSize = platformSettings[0].maxTextureSize;
            TextureImporterCompression textureCompression = platformSettings[0].textureCompression;
            bool crunchedCompression  = platformSettings[0].crunchedCompression;
            int  compressionQuality   = platformSettings[0].compressionQuality;
            bool crunchedCompression2 = crunchedCompression;
            int  compressionQuality2  = compressionQuality;
            bool isMixedValue         = false;
            bool flag          = false;
            bool flag2         = false;
            bool isMixedValue2 = false;
            bool flag3         = false;
            bool flag4         = false;
            bool flag5         = false;
            bool flag6         = false;

            for (int i = 1; i < platformSettings.Count; i++)
            {
                TextureImporterPlatformSettings textureImporterPlatformSettings = platformSettings[i];
                if (textureImporterPlatformSettings.maxTextureSize != maxTextureSize)
                {
                    isMixedValue = true;
                }
                if (textureImporterPlatformSettings.textureCompression != textureCompression)
                {
                    flag = true;
                }
                if (textureImporterPlatformSettings.crunchedCompression != crunchedCompression)
                {
                    flag2 = true;
                }
                if (textureImporterPlatformSettings.compressionQuality != compressionQuality)
                {
                    isMixedValue2 = true;
                }
            }
            int maxTextureSize2 = view.DrawMaxSize(maxTextureSize, isMixedValue, out flag3);
            TextureImporterCompression textureCompression2 = view.DrawCompression(textureCompression, flag, out flag4);

            if (!flag && textureCompression != TextureImporterCompression.Uncompressed)
            {
                crunchedCompression2 = view.DrawUseCrunchedCompression(crunchedCompression, flag2, out flag5);
                if (!flag2 && crunchedCompression)
                {
                    compressionQuality2 = view.DrawCompressionQualitySlider(compressionQuality, isMixedValue2, out flag6);
                }
            }
            bool result;

            if (flag3 || flag4 || flag5 || flag6)
            {
                for (int j = 0; j < platformSettings.Count; j++)
                {
                    if (flag3)
                    {
                        platformSettings[j].maxTextureSize = maxTextureSize2;
                    }
                    if (flag4)
                    {
                        platformSettings[j].textureCompression = textureCompression2;
                    }
                    if (flag5)
                    {
                        platformSettings[j].crunchedCompression = crunchedCompression2;
                    }
                    if (flag6)
                    {
                        platformSettings[j].compressionQuality = compressionQuality2;
                    }
                }
                result = true;
            }
            else
            {
                result = false;
            }
            return(result);
        }
Ejemplo n.º 5
0
        public bool HandlePlatformSettings(BuildTarget buildTarget, List <TextureImporterPlatformSettings> platformSettings, ITexturePlatformSettingsView view, ITexturePlatformSettingsFormatHelper formatHelper)
        {
            Assert.IsTrue(platformSettings.Count > 0, "At least 1 platform setting is needed to display the texture platform setting UI.");

            var allOverride           = platformSettings[0].overridden;
            var allSize               = platformSettings[0].maxTextureSize;
            var allFormat             = platformSettings[0].format;
            var allCompressionQuality = platformSettings[0].compressionQuality;

            var newOverride           = allOverride;
            var newSize               = allSize;
            var newFormat             = allFormat;
            var newCompressionQuality = allCompressionQuality;

            var mixedOverride    = false;
            var mixedSize        = false;
            var mixedFormat      = false;
            var mixedCompression = false;

            var overrideChanged    = false;
            var sizeChanged        = false;
            var formatChanged      = false;
            var compressionChanged = false;

            for (var i = 1; i < platformSettings.Count; ++i)
            {
                var settings = platformSettings[i];
                if (settings.overridden != allOverride)
                {
                    mixedOverride = true;
                }
                if (settings.maxTextureSize != allSize)
                {
                    mixedSize = true;
                }
                if (settings.format != allFormat)
                {
                    mixedFormat = true;
                }
                if (settings.compressionQuality != allCompressionQuality)
                {
                    mixedCompression = true;
                }
            }

            newOverride = view.DrawOverride(allOverride, mixedOverride, out overrideChanged);

            if (!mixedOverride && allOverride)
            {
                newSize = view.DrawMaxSize(allSize, mixedSize, out sizeChanged);
            }

            int[]    formatValues  = null;
            string[] formatStrings = null;
            formatHelper.AcquireTextureFormatValuesAndStrings(buildTarget, out formatValues, out formatStrings);

            newFormat = view.DrawFormat(allFormat, formatValues, formatStrings, mixedFormat, mixedOverride || !allOverride, out formatChanged);

            if (!mixedFormat && !mixedOverride && allOverride && formatHelper.TextureFormatRequireCompressionQualityInput(allFormat))
            {
                bool showAsEnum =
                    buildTarget == BuildTarget.iOS ||
                    buildTarget == BuildTarget.tvOS ||
                    buildTarget == BuildTarget.Android
                ;

                if (showAsEnum)
                {
                    var compressionMode = 1;
                    if (allCompressionQuality == (int)TextureCompressionQuality.Fast)
                    {
                        compressionMode = 0;
                    }
                    else if (allCompressionQuality == (int)TextureCompressionQuality.Best)
                    {
                        compressionMode = 2;
                    }

                    var returnValue = view.DrawCompressionQualityPopup(compressionMode, mixedCompression, out compressionChanged);

                    if (compressionChanged)
                    {
                        switch (returnValue)
                        {
                        case 0: newCompressionQuality = (int)TextureCompressionQuality.Fast; break;

                        case 1: newCompressionQuality = (int)TextureCompressionQuality.Normal; break;

                        case 2: newCompressionQuality = (int)TextureCompressionQuality.Best; break;

                        default:
                            Assert.IsTrue(false, "ITexturePlatformSettingsView.DrawCompressionQualityPopup should never return compression option value that's not 0, 1 or 2.");
                            break;
                        }
                    }
                }
                else
                {
                    newCompressionQuality = view.DrawCompressionQualitySlider(allCompressionQuality, mixedCompression, out compressionChanged);
                }
            }

            if (overrideChanged || sizeChanged || formatChanged || compressionChanged)
            {
                for (var i = 0; i < platformSettings.Count; ++i)
                {
                    if (overrideChanged)
                    {
                        platformSettings[i].overridden = newOverride;
                    }
                    if (sizeChanged)
                    {
                        platformSettings[i].maxTextureSize = newSize;
                    }
                    if (formatChanged)
                    {
                        platformSettings[i].format = newFormat;
                    }
                    if (compressionChanged)
                    {
                        platformSettings[i].compressionQuality = newCompressionQuality;
                    }
                }

                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 6
0
        public bool HandleDefaultSettings(List <TextureImporterPlatformSettings> platformSettings, ITexturePlatformSettingsView view)
        {
            Assert.IsTrue(platformSettings.Count > 0, "At least 1 platform setting is needed to display the texture platform setting UI.");

            var allSize                   = platformSettings[0].maxTextureSize;
            var allCompression            = platformSettings[0].textureCompression;
            var allUseCrunchedCompression = platformSettings[0].crunchedCompression;
            var allCompressionQuality     = platformSettings[0].compressionQuality;

            var newSize                   = allSize;
            var newCompression            = allCompression;
            var newUseCrunchedCompression = allUseCrunchedCompression;
            var newCompressionQuality     = allCompressionQuality;

            var mixedSize                   = false;
            var mixedCompression            = false;
            var mixedUseCrunchedCompression = false;
            var mixedCompressionQuality     = false;

            var sizeChanged                   = false;
            var compressionChanged            = false;
            var useCrunchedCompressionChanged = false;
            var compressionQualityChanged     = false;

            for (var i = 1; i < platformSettings.Count; ++i)
            {
                var settings = platformSettings[i];
                if (settings.maxTextureSize != allSize)
                {
                    mixedSize = true;
                }
                if (settings.textureCompression != allCompression)
                {
                    mixedCompression = true;
                }
                if (settings.crunchedCompression != allUseCrunchedCompression)
                {
                    mixedUseCrunchedCompression = true;
                }
                if (settings.compressionQuality != allCompressionQuality)
                {
                    mixedCompressionQuality = true;
                }
            }

            newSize        = view.DrawMaxSize(allSize, mixedSize, out sizeChanged);
            newCompression = view.DrawCompression(allCompression, mixedCompression, out compressionChanged);
            if (!mixedCompression && allCompression != TextureImporterCompression.Uncompressed)
            {
                newUseCrunchedCompression = view.DrawUseCrunchedCompression(allUseCrunchedCompression, mixedUseCrunchedCompression, out useCrunchedCompressionChanged);

                if (!mixedUseCrunchedCompression && allUseCrunchedCompression)
                {
                    newCompressionQuality = view.DrawCompressionQualitySlider(allCompressionQuality, mixedCompressionQuality, out compressionQualityChanged);
                }
            }

            if (sizeChanged || compressionChanged || useCrunchedCompressionChanged || compressionQualityChanged)
            {
                for (var i = 0; i < platformSettings.Count; ++i)
                {
                    if (sizeChanged)
                    {
                        platformSettings[i].maxTextureSize = newSize;
                    }
                    if (compressionChanged)
                    {
                        platformSettings[i].textureCompression = newCompression;
                    }
                    if (useCrunchedCompressionChanged)
                    {
                        platformSettings[i].crunchedCompression = newUseCrunchedCompression;
                    }
                    if (compressionQualityChanged)
                    {
                        platformSettings[i].compressionQuality = newCompressionQuality;
                    }
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }