Beispiel #1
0
        private Vector2 GetUWPImageTypeSize(PlayerSettings.WSAImageType type, PlayerSettings.WSAImageScale scale)
        {
            Vector2 size = Vector2.zero;

            switch (scale)
            {
            case PlayerSettings.WSAImageScale.Target16:
                size = CreateSize(16);
                break;

            case PlayerSettings.WSAImageScale.Target24:
                size = CreateSize(24);
                break;

            case PlayerSettings.WSAImageScale.Target32:
                size = CreateSize(32);
                break;

            case PlayerSettings.WSAImageScale.Target48:
                size = CreateSize(48);
                break;

            case PlayerSettings.WSAImageScale.Target256:
                size = CreateSize(256);
                break;

            default:
                size = GetWSAImageTypeSize(type, scale);
                break;
            }

            return(size);
        }
Beispiel #2
0
        private static Vector2 GetWSAImageTypeSize(PlayerSettings.WSAImageType type, PlayerSettings.WSAImageScale scale)
        {
            float scaleFactor = float.Parse(scale.ToString().Replace("_", "")) * 0.01f;

            switch (type)
            {
            case PlayerSettings.WSAImageType.PackageLogo:
                return(CreateSquareSize(50, scaleFactor));

            case PlayerSettings.WSAImageType.UWPSquare44x44Logo:
                return(CreateSquareSize(44, scaleFactor));

            case PlayerSettings.WSAImageType.UWPSquare71x71Logo:
                return(CreateSquareSize(71, scaleFactor));

            case PlayerSettings.WSAImageType.UWPSquare150x150Logo:
                return(CreateSquareSize(150, scaleFactor));

            case PlayerSettings.WSAImageType.UWPSquare310x310Logo:
                return(CreateSquareSize(310, scaleFactor));

            // WIDE 31:15
            case PlayerSettings.WSAImageType.UWPWide310x150Logo:
                return(CreateSize(new Vector2(310, 150), scaleFactor));

            case PlayerSettings.WSAImageType.SplashScreenImage:
                return(CreateSize(new Vector2(620, 300), scaleFactor));

            default:
                Debug.LogWarningFormat("Invalid image size for {0} with scale {1}X{2}", type, scale, scaleFactor);
                return(Vector2.zero);
            }
        }
    protected string CopyImage(PlayerSettings.WSAImageType type, PlayerSettings.WSAImageScale scale, string defaultSource, string destinationFileName)
    {
        string visualAssetsImage = PlayerSettings.WSA.GetVisualAssetsImage(type, scale);

        if (string.IsNullOrEmpty(visualAssetsImage))
        {
            if (string.IsNullOrEmpty(defaultSource))
            {
                return(null);
            }
            visualAssetsImage = defaultSource;
        }
        destinationFileName = Path.ChangeExtension(destinationFileName, Path.GetExtension(visualAssetsImage));
        string str3 = Path.ChangeExtension(Utility.CombinePath("Assets", Path.GetFileName(!string.IsNullOrEmpty(defaultSource) ? defaultSource : visualAssetsImage)), Path.GetExtension(visualAssetsImage));

        if (string.IsNullOrEmpty(destinationFileName))
        {
            destinationFileName = str3;
        }
        else
        {
            destinationFileName = Utility.CombinePath("Assets", Path.GetFileName(destinationFileName));
        }
        string path = Utility.CombinePath(base.StagingArea, destinationFileName);

        Utility.CreateDirectory(Path.GetDirectoryName(path));
        FileUtil.CopyFileOrDirectory(visualAssetsImage, path);
        return(destinationFileName.Substring(0, destinationFileName.IndexOf('.')) + Path.GetExtension(visualAssetsImage));
    }
Beispiel #4
0
        private static Vector2 GetWSAImageTypeSize(PlayerSettings.WSAImageType type, PlayerSettings.WSAImageScale scale)
        {
            switch (type)
            {
            case PlayerSettings.WSAImageType.PackageLogo:
                return(CreateSize(50));

                return(CreateSize(150));

                return(CreateSize(30));

                return(CreateSize(70));

                return(CreateSize(310));

                return(CreateSize(44));

                return(CreateSize(71));

                return(CreateSize(150));

            case PlayerSettings.WSAImageType.UWPSquare44x44Logo:
                return(CreateSize(44));

            case PlayerSettings.WSAImageType.UWPSquare71x71Logo:
                return(CreateSize(71));

            case PlayerSettings.WSAImageType.UWPSquare150x150Logo:
                return(CreateSize(150));

            case PlayerSettings.WSAImageType.UWPSquare310x310Logo:
                return(CreateSize(310));

            // WIDE 31:15


            case PlayerSettings.WSAImageType.UWPWide310x150Logo:
                return(new Vector2(310, 150));

            case PlayerSettings.WSAImageType.SplashScreenImage:
                return(new Vector2(620, 300));

            default:
                var   size        = Vector2.zero;
                float scaleFactor = float.Parse(scale.ToString().Replace("_", "")) * 0.01f;
                size   = size * scaleFactor;
                size.x = (float)Math.Ceiling(size.x);
                size.y = (float)Math.Ceiling(size.y);

                if (size == Vector2.zero)
                {
                    Debug.LogWarningFormat("Invalid image size for {0} with scale {1}", type, scale);
                }

                return(size);
            }
        }
Beispiel #5
0
        private static Vector2 GetWSAImageTypeSize(PlayerSettings.WSAImageType type, PlayerSettings.WSAImageScale scale)
        {
            float scaleFactor = float.Parse(scale.ToString().Replace("_", "")) * 0.01f;

            switch (type)
            {
            case PlayerSettings.WSAImageType.PackageLogo:
                return(CreateSquareSize(50, scaleFactor));

            //case PlayerSettings.WSAImageType.StoreTileLogo:
            //return CreateSquareSize(150, scaleFactor);
            //case PlayerSettings.WSAImageType.StoreTileSmallLogo:
            //return CreateSquareSize(30, scaleFactor);
            //case PlayerSettings.WSAImageType.StoreSmallTile:
            //return CreateSquareSize(70, scaleFactor);
            //case PlayerSettings.WSAImageType.StoreLargeTile:
            //return CreateSquareSize(310, scaleFactor);
            //case PlayerSettings.WSAImageType.PhoneAppIcon:
            //return CreateSquareSize(44, scaleFactor);
            //case PlayerSettings.WSAImageType.PhoneSmallTile:
            //return CreateSquareSize(71, scaleFactor);
            //case PlayerSettings.WSAImageType.PhoneMediumTile:
            //return CreateSquareSize(150, scaleFactor);
            case PlayerSettings.WSAImageType.UWPSquare44x44Logo:
                return(CreateSquareSize(44, scaleFactor));

            case PlayerSettings.WSAImageType.UWPSquare71x71Logo:
                return(CreateSquareSize(71, scaleFactor));

            case PlayerSettings.WSAImageType.UWPSquare150x150Logo:
                return(CreateSquareSize(150, scaleFactor));

            case PlayerSettings.WSAImageType.UWPSquare310x310Logo:
                return(CreateSquareSize(310, scaleFactor));

            // WIDE 31:15
            //case PlayerSettings.WSAImageType.PhoneWideTile:
            //case PlayerSettings.WSAImageType.StoreTileWideLogo:
            case PlayerSettings.WSAImageType.UWPWide310x150Logo:
                return(CreateSize(new Vector2(310, 150), scaleFactor));

            case PlayerSettings.WSAImageType.SplashScreenImage:
                return(CreateSize(new Vector2(620, 300), scaleFactor));

            //case PlayerSettings.WSAImageType.PhoneSplashScreen:
            default:
                var size = CreateSquareSize(0, scaleFactor);

                if (size == Vector2.zero)
                {
                    Debug.LogWarningFormat("Invalid image size for {0} with scale {1}", type, scale);
                }

                return(size);
            }
        }
        private static string CloneAndResizeToFile(PlayerSettings.WSAImageType type, PlayerSettings.WSAImageScale scale)
        {
            string texturePath = GetUWPImageTypeTexture(type, scale);

            if (string.IsNullOrEmpty(texturePath))
            {
                return(string.Empty);
            }

            var iconSize = GetUWPImageTypeSize(type, scale);

            if (iconSize == Vector2.zero)
            {
                return(string.Empty);
            }

            if (iconSize.x == 1240 && iconSize.y == 1240 || iconSize.x == 2480 && iconSize.y == 1200)
            {
                return(texturePath);
            }

            string filePath = string.Format("{0}/{1}_{2}x{3}.png", _outputDirectoryName, type.ToString(), iconSize.x, iconSize.y);

            filePath = filePath.Replace(Application.dataPath, "Assets");

            // Create copy of original image
            try
            {
                AssetDatabase.CopyAsset(texturePath, filePath);
                var clone = AssetDatabase.LoadAssetAtPath <Texture2D>(filePath);

                if (clone == null)
                {
                    Debug.LogError("Unable to load texture at " + filePath);
                    return(string.Empty);
                }

                // Resize clone to desired size
                TextureScale.Bilinear(clone, (int)iconSize.x, (int)iconSize.y);
                clone.Compress(true);
                AssetDatabase.SaveAssets();

                if (clone.GetRawTextureData().Length > 204800)
                {
                    Debug.LogWarningFormat("{0} exceeds the minimum file size of 204,800 bytes, please use a smaller image for generating your icons.", clone.name);
                    return(string.Empty);
                }
            }
            catch (Exception e)
            {
                Debug.LogError(e.Message);
                return(string.Empty);
            }

            return(filePath);
        }
Beispiel #7
0
 public MetroScaledImage(PlayerSettings.WSAImageType type, PlayerSettings.WSAImageScale scale, string label, int width, int height)
 {
     this.type      = type;
     this.scale     = scale;
     this.label     = label;
     this.width     = width;
     this.height    = height;
     this.imagePath = null;
     this.image     = null;
 }
Beispiel #8
0
 public override void OnEnable(PlayerSettingsEditor settingsEditor)
 {
     this.m_SettingsEditor                          = settingsEditor;
     this.m_GUIDefaultIsFullScreen                  = EditorGUIUtility.TextContent("Default Is Full Screen*");
     this.m_CompanyName                             = settingsEditor.FindPropertyAssert("companyName");
     this.m_ProductName                             = settingsEditor.FindPropertyAssert("productName");
     this.m_DefaultIsFullScreen                     = settingsEditor.FindPropertyAssert("defaultIsFullScreen");
     this.m_RunInBackground                         = settingsEditor.FindPropertyAssert("runInBackground");
     this.m_MetroPackageName                        = settingsEditor.FindPropertyAssert("metroPackageName");
     this.m_MetroPackageName.stringValue            = Utility.TryValidatePackageName(this.m_MetroPackageName.stringValue);
     this.m_MetroPackageVersion                     = settingsEditor.FindPropertyAssert("metroPackageVersion");
     this.m_MetroPackageVersion.stringValue         = PlayerSettings.WSA.ValidatePackageVersion(this.m_MetroPackageVersion.stringValue);
     this.m_MetroApplicationDescription             = settingsEditor.FindPropertyAssert("metroApplicationDescription");
     this.m_MetroApplicationDescription.stringValue = this.ValidateMetroApplicationDescription(this.m_MetroApplicationDescription.stringValue);
     this.m_MetroTileShortName                      = settingsEditor.FindPropertyAssert("metroTileShortName");
     this.m_MetroTileShortName.stringValue          = this.ValidateMetroTileShortName(this.m_MetroTileShortName.stringValue);
     this.m_MetroTileBackgroundColor                = settingsEditor.FindPropertyAssert("metroTileBackgroundColor");
     this.m_MetroFTAName                            = settingsEditor.FindPropertyAssert("metroFTAName");
     this.m_MetroFTAFileTypes                       = settingsEditor.FindPropertyAssert("metroFTAFileTypes");
     this.m_MetroProtocolName                       = settingsEditor.FindPropertyAssert("metroProtocolName");
     PlayerSettings.WSAImageScale[] scales      = new PlayerSettings.WSAImageScale[] { PlayerSettings.WSAImageScale._80 };
     PlayerSettings.WSAImageScale[] scaleArray2 = new PlayerSettings.WSAImageScale[] { PlayerSettings.WSAImageScale._100 };
     PlayerSettings.WSAImageScale[] scaleArray3 = new PlayerSettings.WSAImageScale[] { PlayerSettings.WSAImageScale._100 };
     this.m_PackageLogos = CreateScaledSquareImageGroup(PlayerSettings.WSAImageType.PackageLogo, new PlayerSettings.WSAImageScale[] { PlayerSettings.WSAImageScale._100 }, "Scale {0}% ({1}x{2} pixels)|Specifies the image that appears on the Store description page for the product.", new int[] { 50, 0x3f, 70, 0x4b, 90, 100, 120, 200 });
     MetroScaledImage[] sourceArray      = CreateScaledSquareImages(PlayerSettings.WSAImageType.StoreTileSmallLogo, scales, "Scale {0}% ({1}x{2} pixels)|Specifies the image that is shown when viewing all installed applications.", new int[] { 0x18, 30, 0x2a, 0x36 });
     MetroScaledImage[] imageArray2      = CreateScaledSquareImages(PlayerSettings.WSAImageType.StoreTileSmallLogo, new PlayerSettings.WSAImageScale[] { PlayerSettings.WSAImageScale.Target16 }, "Target size {0} ({1}x{2} pixels)|Specifies the image that is shown when viewing all installed applications.", new int[] { 0x10, 0x20, 0x30, 0x100 });
     MetroScaledImage[] destinationArray = new MetroScaledImage[sourceArray.Length + imageArray2.Length];
     Array.Copy(sourceArray, destinationArray, sourceArray.Length);
     Array.Copy(imageArray2, 0, destinationArray, sourceArray.Length, imageArray2.Length);
     this.m_StoreSmallLogos  = new MetroScaledImageGroup(destinationArray);
     this.m_MediumTiles      = CreateScaledSquareImageGroup(PlayerSettings.WSAImageType.StoreTileLogo, scales, "Scale {0}% ({1}x{2} pixels)|Specifies the image to display on the app's tile in Windows.", new int[] { 120, 150, 210, 270 });
     this.m_WideTiles        = CreateScaledImageGroup(PlayerSettings.WSAImageType.StoreTileWideLogo, scales, "Scale {0}% ({1}x{2} pixels)|Specifies the image to display on the app's wide tile in Windows if supported.", new int[] { 0xf8, 310, 0x1b2, 0x22e }, new int[] { 120, 150, 210, 270 });
     this.m_SmallTiles       = CreateScaledSquareImageGroup(PlayerSettings.WSAImageType.StoreSmallTile, scales, "Scale {0}% ({1}x{2} pixels)|Specifies the image to display on the app's small tile in Windows if supported.", new int[] { 0x38, 70, 0x62, 0x7e });
     this.m_LargeTiles       = CreateScaledSquareImageGroup(PlayerSettings.WSAImageType.StoreLargeTile, scales, "Scale {0}% ({1}x{2} pixels)|Specifies the image to display on the app's large tile in Windows if supported.", new int[] { 0xf8, 310, 0x1b2, 0x22e });
     this.m_PhoneAppIcons    = CreateScaledSquareImageGroup(PlayerSettings.WSAImageType.PhoneAppIcon, scaleArray2, "Scale {0}% ({1}x{2} pixels)|Specifies the image to display on the app's small tile.", new int[] { 0x2c, 0x3e, 0x6a });
     this.m_PhoneSmallTiles  = CreateScaledSquareImageGroup(PlayerSettings.WSAImageType.PhoneSmallTile, scaleArray2, "Scale {0}% ({1}x{2} pixels)|Specifies the image to display on the app's small tile", new int[] { 0x47, 0x63, 170 });
     this.m_PhoneMediumTiles = CreateScaledSquareImageGroup(PlayerSettings.WSAImageType.PhoneMediumTile, scaleArray2, "Scale {0}% ({1}x{2} pixels)|Specifies the image to display on the app's tile.", new int[] { 150, 210, 360 });
     this.m_PhoneWideTiles   = CreateScaledImageGroup(PlayerSettings.WSAImageType.PhoneWideTile, scaleArray2, "Scale {0}% ({1}x{2} pixels)|Specifies the image to display on the app's wide tile.", new int[] { 310, 0x1b2, 0x2e8 }, new int[] { 150, 210, 360 });
     MetroScaledImage[] imageArray4 = CreateScaledSquareImages(PlayerSettings.WSAImageType.UWPSquare44x44Logo, scaleArray3, "Scale {0}% ({1}x{2} pixels)|Specifies the image to display on the app's tile.", new int[] { 0x2c, 0x37, 0x42, 0x58, 0xb0 });
     MetroScaledImage[] imageArray5 = CreateScaledSquareImages(PlayerSettings.WSAImageType.UWPSquare44x44Logo, new PlayerSettings.WSAImageScale[] { PlayerSettings.WSAImageScale.Target16 }, "Target size {0} ({1}x{2} pixels)|Specifies the image to display on the app's tile.", new int[] { 0x10, 0x18, 0x30, 0x100 });
     MetroScaledImage[] imageArray6 = new MetroScaledImage[imageArray4.Length + imageArray5.Length];
     Array.Copy(imageArray4, imageArray6, imageArray4.Length);
     Array.Copy(imageArray5, 0, imageArray6, imageArray4.Length, imageArray5.Length);
     this.m_UWPSquare44x44Logos            = new MetroScaledImageGroup(imageArray6);
     this.m_UWPSquare71x71Logos            = CreateScaledSquareImageGroup(PlayerSettings.WSAImageType.UWPSquare71x71Logo, scaleArray3, "Scale {0}% ({1}x{2} pixels)|Specifies the image to display on the app's tile.", new int[] { 0x47, 0x59, 0x6b, 0x8e, 0x11c });
     this.m_UWPSquare150x150Logos          = CreateScaledSquareImageGroup(PlayerSettings.WSAImageType.UWPSquare150x150Logo, scaleArray3, "Scale {0}% ({1}x{2} pixels)|Specifies the image to display on the app's tile.", new int[] { 150, 0xbc, 0xe1, 300, 600 });
     this.m_UWPSquare310x310Logos          = CreateScaledSquareImageGroup(PlayerSettings.WSAImageType.UWPSquare310x310Logo, scaleArray3, "Scale {0}% ({1}x{2} pixels)|Specifies the image to display on the app's tile.", new int[] { 310, 0x184, 0x1d1, 620, 0x4d8 });
     this.m_UWPWide310x150Logos            = CreateScaledImageGroup(PlayerSettings.WSAImageType.UWPWide310x150Logo, scaleArray3, "Scale {0}% ({1}x{2} pixels)|Specifies the image to display on the app's tile.", new int[] { 310, 0x184, 0x1d1, 620, 0x4d8 }, new int[] { 150, 0xbc, 0xe1, 300, 600 });
     this.m_WindowsSplashScreens           = CreateScaledImages(PlayerSettings.WSAImageType.SplashScreenImage, new PlayerSettings.WSAImageScale[] { PlayerSettings.WSAImageScale._100 }, "Scale {0}% ({1}x{2} pixels)|Sets the foreground image for the app's splash screen.", new int[] { 620, 0x307, 0x364, 930, 0x45c, 0x4d8, 0x9b0 }, new int[] { 300, 0x177, 420, 450, 540, 600, 0x4b0 });
     this.m_PhoneSplashScreens             = CreateScaledImages(PlayerSettings.WSAImageType.PhoneSplashScreen, scaleArray2, "Scale {0}% ({1}x{2} pixels)|Sets the foreground image for the app's splash screen.", new int[] { 480, 0x2a0, 0x480 }, new int[] { 800, 0x460, 0x780 });
     this.m_HolographicSplashScreen        = settingsEditor.FindPropertyAssert("m_VirtualRealitySplashScreen");
     this.m_HolographicPauseOnTrackingLoss = settingsEditor.FindPropertyAssert("m_HolographicPauseOnTrackingLoss");
     this.m_HolographicTrackingLossScreen  = settingsEditor.FindPropertyAssert("m_HolographicTrackingLossScreen");
 }
Beispiel #9
0
        private Texture2D GetUWPImageTypeTexture(PlayerSettings.WSAImageType type, PlayerSettings.WSAImageScale scale)
        {
            switch (type)
            {
            case PlayerSettings.WSAImageType.PackageLogo:
            case PlayerSettings.WSAImageType.StoreTileLogo:
            case PlayerSettings.WSAImageType.StoreTileSmallLogo:
            case PlayerSettings.WSAImageType.StoreSmallTile:
            case PlayerSettings.WSAImageType.StoreLargeTile:
            case PlayerSettings.WSAImageType.PhoneAppIcon:
            case PlayerSettings.WSAImageType.PhoneSmallTile:
            case PlayerSettings.WSAImageType.PhoneMediumTile:
            case PlayerSettings.WSAImageType.PhoneWideTile:
            case PlayerSettings.WSAImageType.PhoneSplashScreen:
            case PlayerSettings.WSAImageType.UWPSquare44x44Logo:
            case PlayerSettings.WSAImageType.UWPSquare71x71Logo:
            case PlayerSettings.WSAImageType.UWPSquare150x150Logo:
            case PlayerSettings.WSAImageType.UWPSquare310x310Logo:
                return(_originalAppIcon);

            case PlayerSettings.WSAImageType.SplashScreenImage:
            case PlayerSettings.WSAImageType.StoreTileWideLogo:
            case PlayerSettings.WSAImageType.UWPWide310x150Logo:
                if (scale != PlayerSettings.WSAImageScale.Target16 &&
                    scale != PlayerSettings.WSAImageScale.Target24 &&
                    scale != PlayerSettings.WSAImageScale.Target32 &&
                    scale != PlayerSettings.WSAImageScale.Target48 &&
                    scale != PlayerSettings.WSAImageScale.Target256)
                {
                    return(_originalSplashImage);
                }
                else
                {
                    break;
                }

            default:
                break;
            }

            return(null);
        }
Beispiel #10
0
        private void ImageField(PlayerSettings.WSAImageType type, PlayerSettings.WSAImageScale scale, GUIContent label, int imageWidth, int imageHeight, ref string imagePath, ref Texture2D image)
        {
            if (imagePath == null)
            {
                imagePath = PlayerSettings.WSA.GetVisualAssetsImage(type, scale);
            }
            if ((image == null) && !string.IsNullOrEmpty(imagePath))
            {
                image = AssetDatabase.LoadAssetAtPath <Texture2D>(imagePath);
            }
            Texture2D assetObject = (Texture2D)EditorGUILayout.ObjectField(label, image, typeof(Texture2D), false, new GUILayoutOption[0]);
            string    b           = (assetObject == null) ? "" : AssetDatabase.GetAssetPath(assetObject);

            if (!string.Equals(imagePath, b) && (!string.IsNullOrEmpty(b) ? ValidateImage(b, imageWidth, imageHeight) : true))
            {
                Undo.RecordObject(this.m_SettingsEditor.serializedObject.targetObject, "Change WSA Visual Asset");
                PlayerSettings.WSA.SetVisualAssetsImage(b, type, scale);
                imagePath = b;
                image     = assetObject;
            }
        }
Beispiel #11
0
        private static Vector2 GetUWPImageTypeSize(PlayerSettings.WSAImageType type, PlayerSettings.WSAImageScale scale)
        {
            switch (scale)
            {
            case PlayerSettings.WSAImageScale.Target16:
                return(CreateSquareSize(16));

            case PlayerSettings.WSAImageScale.Target24:
                return(CreateSquareSize(24));

            case PlayerSettings.WSAImageScale.Target32:
                return(CreateSquareSize(32));

            case PlayerSettings.WSAImageScale.Target48:
                return(CreateSquareSize(48));

            case PlayerSettings.WSAImageScale.Target256:
                return(CreateSquareSize(256));

            default:
                return(GetWSAImageTypeSize(type, scale));
            }
        }
Beispiel #12
0
        private static string GetUWPImageTypeTexture(PlayerSettings.WSAImageType type, PlayerSettings.WSAImageScale scale)
        {
            switch (type)
            {
            case PlayerSettings.WSAImageType.PackageLogo:
            case PlayerSettings.WSAImageType.UWPSquare44x44Logo:
            case PlayerSettings.WSAImageType.UWPSquare71x71Logo:
            case PlayerSettings.WSAImageType.UWPSquare150x150Logo:
            case PlayerSettings.WSAImageType.UWPSquare310x310Logo:
                return(_newAppIconPath);

            case PlayerSettings.WSAImageType.SplashScreenImage:
            case PlayerSettings.WSAImageType.UWPWide310x150Logo:
                if (scale != PlayerSettings.WSAImageScale.Target16 &&
                    scale != PlayerSettings.WSAImageScale.Target24 &&
                    scale != PlayerSettings.WSAImageScale.Target32 &&
                    scale != PlayerSettings.WSAImageScale.Target48 &&
                    scale != PlayerSettings.WSAImageScale.Target256)
                {
                    return(_newSplashImagePath);
                }
                else
                {
                    return(_newAppIconPath);
                }

            default:
                throw new ArgumentOutOfRangeException("type", type, null);
            }
        }
Beispiel #13
0
        private static string CloneAndResizeToFile(PlayerSettings.WSAImageType type, PlayerSettings.WSAImageScale scale)
        {
            string texturePath = GetUWPImageTypeTexture(type, scale);

            if (string.IsNullOrEmpty(texturePath))
            {
                return(string.Empty);
            }

            var iconSize = GetUWPImageTypeSize(type, scale);

            if (iconSize == Vector2.zero)
            {
                return(string.Empty);
            }

            if (iconSize.x == 1240 && iconSize.y == 1240 || iconSize.x == 2480 && iconSize.y == 1200)
            {
                return(texturePath);
            }

            string filePath = string.Format("{0}/{1}_AppIcon_{2}x{3}.png", _outputDirectoryName, Application.productName, iconSize.x, iconSize.y);

            filePath = filePath.Replace(Application.dataPath, "Assets");

            if (File.Exists(filePath))
            {
                return(filePath);
            }

            // Create copy of original image
            try
            {
                AssetDatabase.CopyAsset(texturePath, filePath);
                var clone = AssetDatabase.LoadAssetAtPath <Texture2D>(filePath);

                if (clone == null)
                {
                    Debug.LogError("Unable to load texture at " + filePath);
                    return(string.Empty);
                }

                // Resize clone to desired size
                TextureScale.Bilinear(clone, (int)iconSize.x, (int)iconSize.y);

                // Crop
                Color[] pix = clone.GetPixels(0, 0, (int)iconSize.x, (int)iconSize.y);
                clone = new Texture2D((int)iconSize.x, (int)iconSize.y, TextureFormat.ARGB32, false);
                clone.SetPixels(pix);
                clone.Apply();

                var rawData = clone.EncodeToPNG();
                File.WriteAllBytes(filePath, rawData);

                if (rawData.Length > 204800)
                {
                    Debug.LogWarningFormat("{0} exceeds the minimum file size of 204,800 bytes, please use a smaller image for generating your icons.", filePath);
                }
            }
            catch (Exception e)
            {
                Debug.LogError(e.Message);
                return(string.Empty);
            }

            return(filePath);
        }
 public MetroScaledImage(PlayerSettings.WSAImageType type, PlayerSettings.WSAImageScale scale, string label, int width, int height)
 {
     this.type = type;
     this.scale = scale;
     this.label = label;
     this.width = width;
     this.height = height;
     this.imagePath = null;
     this.image = null;
 }
 public override void OnEnable(PlayerSettingsEditor settingsEditor)
 {
     this.m_SettingsEditor = settingsEditor;
     this.m_GUIDefaultIsFullScreen = EditorGUIUtility.TextContent("Default Is Full Screen*");
     this.m_CompanyName = settingsEditor.FindPropertyAssert("companyName");
     this.m_ProductName = settingsEditor.FindPropertyAssert("productName");
     this.m_DefaultIsFullScreen = settingsEditor.FindPropertyAssert("defaultIsFullScreen");
     this.m_RunInBackground = settingsEditor.FindPropertyAssert("runInBackground");
     this.m_MetroPackageName = settingsEditor.FindPropertyAssert("metroPackageName");
     this.m_MetroPackageName.stringValue = Utility.TryValidatePackageName(this.m_MetroPackageName.stringValue);
     this.m_MetroPackageVersion = settingsEditor.FindPropertyAssert("metroPackageVersion");
     this.m_MetroPackageVersion.stringValue = PlayerSettings.WSA.ValidatePackageVersion(this.m_MetroPackageVersion.stringValue);
     this.m_MetroApplicationDescription = settingsEditor.FindPropertyAssert("metroApplicationDescription");
     this.m_MetroApplicationDescription.stringValue = this.ValidateMetroApplicationDescription(this.m_MetroApplicationDescription.stringValue);
     this.m_MetroTileShortName = settingsEditor.FindPropertyAssert("metroTileShortName");
     this.m_MetroTileShortName.stringValue = this.ValidateMetroTileShortName(this.m_MetroTileShortName.stringValue);
     this.m_MetroTileBackgroundColor = settingsEditor.FindPropertyAssert("metroTileBackgroundColor");
     this.m_MetroFTAName = settingsEditor.FindPropertyAssert("metroFTAName");
     this.m_MetroFTAFileTypes = settingsEditor.FindPropertyAssert("metroFTAFileTypes");
     this.m_MetroProtocolName = settingsEditor.FindPropertyAssert("metroProtocolName");
     PlayerSettings.WSAImageScale[] scales = new PlayerSettings.WSAImageScale[] { PlayerSettings.WSAImageScale._80 };
     PlayerSettings.WSAImageScale[] scaleArray2 = new PlayerSettings.WSAImageScale[] { PlayerSettings.WSAImageScale._100 };
     PlayerSettings.WSAImageScale[] scaleArray3 = new PlayerSettings.WSAImageScale[] { PlayerSettings.WSAImageScale._100 };
     this.m_PackageLogos = CreateScaledSquareImageGroup(PlayerSettings.WSAImageType.PackageLogo, new PlayerSettings.WSAImageScale[] { PlayerSettings.WSAImageScale._100 }, "Scale {0}% ({1}x{2} pixels)|Specifies the image that appears on the Store description page for the product.", new int[] { 50, 0x3f, 70, 0x4b, 90, 100, 120, 200 });
     MetroScaledImage[] sourceArray = CreateScaledSquareImages(PlayerSettings.WSAImageType.StoreTileSmallLogo, scales, "Scale {0}% ({1}x{2} pixels)|Specifies the image that is shown when viewing all installed applications.", new int[] { 0x18, 30, 0x2a, 0x36 });
     MetroScaledImage[] imageArray2 = CreateScaledSquareImages(PlayerSettings.WSAImageType.StoreTileSmallLogo, new PlayerSettings.WSAImageScale[] { PlayerSettings.WSAImageScale.Target16 }, "Target size {0} ({1}x{2} pixels)|Specifies the image that is shown when viewing all installed applications.", new int[] { 0x10, 0x20, 0x30, 0x100 });
     MetroScaledImage[] destinationArray = new MetroScaledImage[sourceArray.Length + imageArray2.Length];
     Array.Copy(sourceArray, destinationArray, sourceArray.Length);
     Array.Copy(imageArray2, 0, destinationArray, sourceArray.Length, imageArray2.Length);
     this.m_StoreSmallLogos = new MetroScaledImageGroup(destinationArray);
     this.m_MediumTiles = CreateScaledSquareImageGroup(PlayerSettings.WSAImageType.StoreTileLogo, scales, "Scale {0}% ({1}x{2} pixels)|Specifies the image to display on the app's tile in Windows.", new int[] { 120, 150, 210, 270 });
     this.m_WideTiles = CreateScaledImageGroup(PlayerSettings.WSAImageType.StoreTileWideLogo, scales, "Scale {0}% ({1}x{2} pixels)|Specifies the image to display on the app's wide tile in Windows if supported.", new int[] { 0xf8, 310, 0x1b2, 0x22e }, new int[] { 120, 150, 210, 270 });
     this.m_SmallTiles = CreateScaledSquareImageGroup(PlayerSettings.WSAImageType.StoreSmallTile, scales, "Scale {0}% ({1}x{2} pixels)|Specifies the image to display on the app's small tile in Windows if supported.", new int[] { 0x38, 70, 0x62, 0x7e });
     this.m_LargeTiles = CreateScaledSquareImageGroup(PlayerSettings.WSAImageType.StoreLargeTile, scales, "Scale {0}% ({1}x{2} pixels)|Specifies the image to display on the app's large tile in Windows if supported.", new int[] { 0xf8, 310, 0x1b2, 0x22e });
     this.m_PhoneAppIcons = CreateScaledSquareImageGroup(PlayerSettings.WSAImageType.PhoneAppIcon, scaleArray2, "Scale {0}% ({1}x{2} pixels)|Specifies the image to display on the app's small tile.", new int[] { 0x2c, 0x3e, 0x6a });
     this.m_PhoneSmallTiles = CreateScaledSquareImageGroup(PlayerSettings.WSAImageType.PhoneSmallTile, scaleArray2, "Scale {0}% ({1}x{2} pixels)|Specifies the image to display on the app's small tile", new int[] { 0x47, 0x63, 170 });
     this.m_PhoneMediumTiles = CreateScaledSquareImageGroup(PlayerSettings.WSAImageType.PhoneMediumTile, scaleArray2, "Scale {0}% ({1}x{2} pixels)|Specifies the image to display on the app's tile.", new int[] { 150, 210, 360 });
     this.m_PhoneWideTiles = CreateScaledImageGroup(PlayerSettings.WSAImageType.PhoneWideTile, scaleArray2, "Scale {0}% ({1}x{2} pixels)|Specifies the image to display on the app's wide tile.", new int[] { 310, 0x1b2, 0x2e8 }, new int[] { 150, 210, 360 });
     MetroScaledImage[] imageArray4 = CreateScaledSquareImages(PlayerSettings.WSAImageType.UWPSquare44x44Logo, scaleArray3, "Scale {0}% ({1}x{2} pixels)|Specifies the image to display on the app's tile.", new int[] { 0x2c, 0x37, 0x42, 0x58, 0xb0 });
     MetroScaledImage[] imageArray5 = CreateScaledSquareImages(PlayerSettings.WSAImageType.UWPSquare44x44Logo, new PlayerSettings.WSAImageScale[] { PlayerSettings.WSAImageScale.Target16 }, "Target size {0} ({1}x{2} pixels)|Specifies the image to display on the app's tile.", new int[] { 0x10, 0x18, 0x30, 0x100 });
     MetroScaledImage[] imageArray6 = new MetroScaledImage[imageArray4.Length + imageArray5.Length];
     Array.Copy(imageArray4, imageArray6, imageArray4.Length);
     Array.Copy(imageArray5, 0, imageArray6, imageArray4.Length, imageArray5.Length);
     this.m_UWPSquare44x44Logos = new MetroScaledImageGroup(imageArray6);
     this.m_UWPSquare71x71Logos = CreateScaledSquareImageGroup(PlayerSettings.WSAImageType.UWPSquare71x71Logo, scaleArray3, "Scale {0}% ({1}x{2} pixels)|Specifies the image to display on the app's tile.", new int[] { 0x47, 0x59, 0x6b, 0x8e, 0x11c });
     this.m_UWPSquare150x150Logos = CreateScaledSquareImageGroup(PlayerSettings.WSAImageType.UWPSquare150x150Logo, scaleArray3, "Scale {0}% ({1}x{2} pixels)|Specifies the image to display on the app's tile.", new int[] { 150, 0xbc, 0xe1, 300, 600 });
     this.m_UWPSquare310x310Logos = CreateScaledSquareImageGroup(PlayerSettings.WSAImageType.UWPSquare310x310Logo, scaleArray3, "Scale {0}% ({1}x{2} pixels)|Specifies the image to display on the app's tile.", new int[] { 310, 0x184, 0x1d1, 620, 0x4d8 });
     this.m_UWPWide310x150Logos = CreateScaledImageGroup(PlayerSettings.WSAImageType.UWPWide310x150Logo, scaleArray3, "Scale {0}% ({1}x{2} pixels)|Specifies the image to display on the app's tile.", new int[] { 310, 0x184, 0x1d1, 620, 0x4d8 }, new int[] { 150, 0xbc, 0xe1, 300, 600 });
     this.m_WindowsSplashScreens = CreateScaledImages(PlayerSettings.WSAImageType.SplashScreenImage, new PlayerSettings.WSAImageScale[] { PlayerSettings.WSAImageScale._100 }, "Scale {0}% ({1}x{2} pixels)|Sets the foreground image for the app's splash screen.", new int[] { 620, 0x307, 0x364, 930, 0x45c, 0x4d8, 0x9b0 }, new int[] { 300, 0x177, 420, 450, 540, 600, 0x4b0 });
     this.m_PhoneSplashScreens = CreateScaledImages(PlayerSettings.WSAImageType.PhoneSplashScreen, scaleArray2, "Scale {0}% ({1}x{2} pixels)|Sets the foreground image for the app's splash screen.", new int[] { 480, 0x2a0, 0x480 }, new int[] { 800, 0x460, 0x780 });
     this.m_HolographicSplashScreen = settingsEditor.FindPropertyAssert("m_VirtualRealitySplashScreen");
     this.m_HolographicPauseOnTrackingLoss = settingsEditor.FindPropertyAssert("m_HolographicPauseOnTrackingLoss");
     this.m_HolographicTrackingLossScreen = settingsEditor.FindPropertyAssert("m_HolographicTrackingLossScreen");
 }
Beispiel #16
0
        private Vector2 GetWSAImageTypeSize(PlayerSettings.WSAImageType type, PlayerSettings.WSAImageScale scale)
        {
            Vector2 size        = Vector2.zero;
            float   scaleFactor = (float)scale / 100;

            switch (type)
            {
            case PlayerSettings.WSAImageType.PackageLogo:
                size = CreateSize(50);
                break;

            case PlayerSettings.WSAImageType.StoreTileLogo:
                size = CreateSize(150);
                break;

            case PlayerSettings.WSAImageType.StoreTileSmallLogo:
                size = CreateSize(30);
                break;

            case PlayerSettings.WSAImageType.StoreSmallTile:
                size = CreateSize(70);
                break;

            case PlayerSettings.WSAImageType.StoreLargeTile:
                size = CreateSize(310);
                break;

            case PlayerSettings.WSAImageType.PhoneAppIcon:
                size = CreateSize(44);
                break;

            case PlayerSettings.WSAImageType.PhoneSmallTile:
                size = CreateSize(71);
                break;

            case PlayerSettings.WSAImageType.PhoneMediumTile:
                size = CreateSize(150);
                break;

            case PlayerSettings.WSAImageType.PhoneSplashScreen:
                break;

            case PlayerSettings.WSAImageType.UWPSquare44x44Logo:
                size = CreateSize(44);
                break;

            case PlayerSettings.WSAImageType.UWPSquare71x71Logo:
                size = CreateSize(71);
                break;

            case PlayerSettings.WSAImageType.UWPSquare150x150Logo:
                size = CreateSize(150);
                break;

            case PlayerSettings.WSAImageType.UWPSquare310x310Logo:
                size = CreateSize(310);
                break;

            // WIDE 31:15
            case PlayerSettings.WSAImageType.PhoneWideTile:
            case PlayerSettings.WSAImageType.StoreTileWideLogo:
            case PlayerSettings.WSAImageType.UWPWide310x150Logo:
                size = new Vector2(310, 150);
                break;

            case PlayerSettings.WSAImageType.SplashScreenImage:
                size = new Vector2(620, 300);
                break;

            default:
                break;
            }

            if (size != Vector2.zero)
            {
                size   = (size * scaleFactor);
                size.x = (float)Math.Ceiling(size.x);
                size.y = (float)Math.Ceiling(size.y);
            }
            return(size);
        }
Beispiel #17
0
        private string CloneAndResizeToFile(Texture2D texture, PlayerSettings.WSAImageType type, PlayerSettings.WSAImageScale scale, ref string fileName)
        {
            var iconSize = GetUWPImageTypeSize(type, scale);

            if (iconSize != Vector2.zero)
            {
                fileName = string.Format("{0}x{1}.png", iconSize.x, iconSize.y);
                return(CloneAndResizeToFile(texture, iconSize, ref fileName));
            }

            return(null);
        }