Beispiel #1
0
        internal static void ShowPlatformSpecificSettings(List <BaseTextureImportPlatformSettings> platformSettings, int selected)
        {
            BaseTextureImportPlatformSettings realPS = platformSettings[selected + 1];

            if (!realPS.model.isDefault)
            {
                EditorGUI.BeginChangeCheck();
                EditorGUI.showMixedValue = realPS.model.overriddenIsDifferent;

                BuildPlatform[] validPlatforms = GetBuildPlayerValidPlatforms();
                string          title          = string.Format(Styles.overrideFor.text, validPlatforms[selected].title.text);
                bool            newOverride    = EditorGUILayout.ToggleLeft(title, realPS.model.platformTextureSettings.overridden);
                EditorGUI.showMixedValue = false;
                if (EditorGUI.EndChangeCheck())
                {
                    realPS.model.SetOverriddenForAll(newOverride);
                    SyncPlatformSettings(platformSettings);
                }
            }

            // Disable size and format GUI if not overwritten for all objects
            bool notAllOverriddenForThisPlatform = (!realPS.model.isDefault && !realPS.model.allAreOverridden);

            using (new EditorGUI.DisabledScope(notAllOverriddenForThisPlatform))
            {
                // acquire the platform support module for this platform, and present the appropriate UI
                ITextureImportSettingsExtension textureSettingsExtension = ModuleManager.GetTextureImportSettingsExtension(realPS.model.buildTarget);
                textureSettingsExtension.ShowImportSettings(realPS);

                //just do this once, regardless of whether things changed
                SyncPlatformSettings(platformSettings);
            }

            EditorGUILayout.EndPlatformGrouping();
        }
        public void Sync()
        {
            // Use settings from default if any of the targets are not overridden
            if (!model.isDefault && (!model.platformTextureSettings.overridden || model.overriddenIsDifferent))
            {
                BaseTextureImportPlatformSettings defaultSettings = GetDefaultImportSettings();
                model.platformTextureSettings.maxTextureSize = defaultSettings.model.platformTextureSettings.maxTextureSize;
                model.maxTextureSizeIsDifferent = defaultSettings.model.maxTextureSizeIsDifferent;
                model.platformTextureSettings.resizeAlgorithm = defaultSettings.model.platformTextureSettings.resizeAlgorithm;
                model.resizeAlgorithmIsDifferent = defaultSettings.model.resizeAlgorithmIsDifferent;
                model.platformTextureSettings.textureCompression = defaultSettings.model.platformTextureSettings.textureCompression;
                model.textureCompressionIsDifferent                = defaultSettings.model.textureCompressionIsDifferent;
                model.platformTextureSettings.format               = defaultSettings.model.platformTextureSettings.format;
                model.textureFormatIsDifferent                     = defaultSettings.model.textureFormatIsDifferent;
                model.platformTextureSettings.compressionQuality   = defaultSettings.model.platformTextureSettings.compressionQuality;
                model.compressionQualityIsDifferent                = defaultSettings.model.compressionQualityIsDifferent;
                model.platformTextureSettings.crunchedCompression  = defaultSettings.model.platformTextureSettings.crunchedCompression;
                model.crunchedCompressionIsDifferent               = defaultSettings.model.crunchedCompressionIsDifferent;
                model.platformTextureSettings.allowsAlphaSplitting = defaultSettings.model.platformTextureSettings.allowsAlphaSplitting;
                model.allowsAlphaSplitIsDifferent                  = defaultSettings.model.allowsAlphaSplitIsDifferent;
                model.androidETC2FallbackOverrideIsDifferent       = defaultSettings.model.androidETC2FallbackOverrideIsDifferent;
            }

            if ((model.platformTextureSettings.overridden || model.overriddenIsDifferent) && model.platformTextureSettings.format < 0)
            {
                var showSettingsForPreset = ShowPresetSettings();

                model.platformTextureSettings.format = TextureImporter.DefaultFormatFromTextureParameters(
                    GetImporterSettings(0),
                    model.platformTextureSettings,
                    showSettingsForPreset || DoesSourceTextureHaveAlpha(0),
                    showSettingsForPreset || IsSourceTextureHDR(0),
                    model.buildTarget
                    );
                model.textureFormatIsDifferent = false;

                for (int i = 1; i < GetTargetCount(); i++)
                {
                    TextureImporterSettings settings = GetImporterSettings(i);

                    TextureImporterFormat format = TextureImporter.DefaultFormatFromTextureParameters(settings,
                                                                                                      model.platformTextureSettings,
                                                                                                      showSettingsForPreset || DoesSourceTextureHaveAlpha(i),
                                                                                                      showSettingsForPreset || IsSourceTextureHDR(i),
                                                                                                      model.buildTarget
                                                                                                      );
                    if (format != model.platformTextureSettings.format)
                    {
                        model.textureFormatIsDifferent = true;
                    }
                }
            }
        }