Exemple #1
0
        /// <summary>
        /// The Post Processor for the common images. How it works:
        /// 1. Get the original image dimensions e.g 400x200
        /// 2. Get the max size of width and height (in this case 400), then get previous power of two of it i.e 256
        /// 3. For android set max size to the POT value, set format to ASTC 8x8
        /// 4. For ios set max size to POT * 2, set format to ASTC 8x8
        /// </summary>
        public static void SetCommonSettings(this TextureImporter importer, SpritePackerData data)
        {
            int w, h;

            importer.GetOriginalImageSize(out w, out h);
            int prevPowerOfTwo = System.Math.Max(w, h).PrevPowerOfTwo();

            prevPowerOfTwo = prevPowerOfTwo.Clamp(data.minSize, data.maxSize);
            // android
            importer.OverridePlatformSettings(PlatformAndroid(), data.formatAndroid, prevPowerOfTwo);
            // ios
            importer.OverridePlatformSettings(PlatformIos(), data.formatIOS, prevPowerOfTwo * 2);

            EditorUtility.SetDirty(importer);
            importer.SaveAndReimport();
        }