Beispiel #1
0
        static void SetPlatformSettings(string platform, TextureImporter importer, SoTexturePostprocessorBase soPostprocessor)
        {
            var soPlatformSettings = soPostprocessor.GetPlatformSettings(platform);
            var platformSettings   = importer.GetPlatformTextureSettings(platform);

            platformSettings.overridden = soPlatformSettings.overridden;
            if (soPlatformSettings.overridden)
            {
                platformSettings.format             = (TextureImporterFormat)soPlatformSettings.format;
                platformSettings.maxTextureSize     = soPlatformSettings.maxTextureSize;
                platformSettings.compressionQuality = (int)soPlatformSettings.compressionQuality;
            }

            importer.SetPlatformTextureSettings(platformSettings);
        }
Beispiel #2
0
        static bool ComparePlatformSetting(string platform, SoTexturePostprocessorBase texturePostprocessorBase, TextureImporter importer, ref string message)
        {
            var so = texturePostprocessorBase.GetPlatformSettings(platform);
            var texturePlatformSettings = importer.GetPlatformTextureSettings(platform);
            var same     = true;
            var sameInfo = string.Empty;

            if (so.overridden != texturePlatformSettings.overridden)
            {
                same     = false;
                sameInfo = StringUtil.Contact(sameInfo, "\n", "overridden");
            }

            if (so.overridden && texturePlatformSettings.overridden)
            {
                if (so.format != (int)texturePlatformSettings.format)
                {
                    same     = false;
                    sameInfo = StringUtil.Contact(sameInfo, "\n", "format");
                }

                if ((int)so.compressionQuality != texturePlatformSettings.compressionQuality)
                {
                    same     = false;
                    sameInfo = StringUtil.Contact(sameInfo, "\n", "compressionQuality");
                }

                if (so.maxTextureSize != texturePlatformSettings.maxTextureSize)
                {
                    same     = false;
                    sameInfo = StringUtil.Contact(sameInfo, "\n", "maxTextureSize");
                }
            }

            if (!same)
            {
                message = StringUtil.Contact(message, "\n", "platform: ", platform, sameInfo);
            }

            return(same);
        }
        public void OnGUI()
        {
            if (this.so == null)
            {
                return;
            }

            GUILayout.BeginVertical(EditorStyles.helpBox);
            GUILayout.BeginHorizontal();
            {
                for (int i = 0; i < Helper.Platforms.Length; i++)
                {
                    if (GUILayout.Toggle(platformIndex == i, Helper.Platforms[i], EditorStyles.toolbarButton))
                    {
                        platformIndex         = i;
                        Helper.SelectPlatform = Helper.Platforms[i];
                    }
                }
            }
            GUILayout.EndHorizontal();

            EditorGUI.BeginChangeCheck();
            using (new EditorGUI.DisabledScope(!allowEdit)) {
                var selectPlatform  = Helper.Platforms[platformIndex];
                var platformSetting = so.GetPlatformSettings(selectPlatform);
                platformSetting.overridden = EditorGUILayout.Toggle(StringUtil.Contact("Override for ", platformSetting.platform), platformSetting.overridden);
                using (new EditorGUI.DisabledScope(!platformSetting.overridden)) {
                    platformSetting.maxTextureSize = EditorGUILayout.IntPopup(styles.TextureSizeLabel, platformSetting.maxTextureSize, Helper.TextureSizeOptionLabels, Helper.TextureSizeOptions);

                    var textureFormatValue = Helper.GetFormatValues(platformSetting.platform);
                    platformSetting.format = EditorGUILayout.IntPopup(styles.FormatLabel, platformSetting.format, textureFormatValue.FormatStrings, textureFormatValue.FormatValues);

                    platformSetting.compressionQuality = (UnityEditor.TextureCompressionQuality)EditorGUILayout.EnumPopup(styles.CompressionQualityLabel, platformSetting.compressionQuality);
                }

                if (EditorGUI.EndChangeCheck())
                {
                    EditorUtility.SetDirty(so);
                }

#if UNITY_2019_2_OR_NEWER
                var isDirty = EditorUtility.IsDirty(so);
#elif UNITY_2018_4_OR_NEWER
                var isDirty = false;
                if (instanceIds != null && dirtyMethodInfo != null)
                {
                    isDirty = (bool)dirtyMethodInfo.Invoke(this, instanceIds);
                }
#endif

                if (isDirty)
                {
                    if (GUILayout.Button("Save", GUILayout.Width(50)))
                    {
                        AssetDatabase.SaveAssets();
                        OnChanged?.Invoke();
                    }
                }
            }

            GUILayout.EndVertical();
        }