Beispiel #1
0
        private static string GetNullKey()
        {
            var nullKey  = "AA625B9BDB3AE0E4";
            var nullIcon = "iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAFBUlEQVRYCdVXa0wcVRT+dvbN7rK0LE8tVBpJTLU/tBFC+OEPhURrfCQ1aSXRxkQwFZOKMdUmNYZqgqbBEEvBV4zGlNYfNlGDIGgULNrq1opoghEIBDbyKrvssju7OzOeMzC8dtqFJU30JGfuuXfuPee7555z5o4BiSTU1dWdThxeGVEUBQMDA+MdHR1v0qhILK+83Zxk0JmeMTc3d1VnHGyYWZZlSJKEeDyOcDiM6elplJaWGmnNpoHoAiClSQFoIKLRqArC5/OhrKxs0yBMejs1mXSHlz3AaxgAe4CJvZKVlYXJyUkpOzubF0vqiw08BL05giDgWmw0GtV33DJQbs1mM6xWK1wuF6amphiV/g50jOkCMBgM0GMGpY2zrIFgmcFYLBY4nU4GESNbZh17CUObArDaOMuaYfYAM/c1EBSYUbJmSbC4bmDDruJgY4rFYur5MwAtIzgWIpEIBgcHEQqFEAwG1cwgEKLH47HTsoi6WOehmwWkeE0WsIGv3zuO/Iw4Pursxf6yvfhrYggfnr2Cintuwvc/jeL5w4cwO34FcOyGYDejrv4k2ru8mJ+fR0lJiYNsL+jYx4YA8K6feOB27CjMRVG+G5+cu4jvBiZAAaF6of7cGDKz8sgzccTFBVh+roEjehX7jrSpHmOvFBcX83FwbKyh6wJgF7OrNWrqilCwWdguIVewGEDykkw1yKBQfkqIdj0DQZnBwaNn1YLFG+AjKigoWFG2pDRpDDR1BmGz2VQjDiuloEEiebHgCdQyEKoEBIZZhiIoaL9wCQfv360GJmcKMwcnEWNeUy11s4BnMvHun6twwkoxZDWIFNIibEIUNmMcaaYYsYQ0MzH1LTTHIodhkxfQ1vk77TikpqaWnksArIuaV57XBaBNSzMrZEiB06LATkbtJplASLCSLMgihHgIl/t9cGEEJ448hNKyclzw71U3sLpekL6EtEx6BAzCZmavyYhJClpbf8X0yC/kdRNM8gwkIR1Gu4CIrw25jz+M2oYP8G1zPb7p/BINd1TgaFU5q1CDlZqEGEgYoEkZq9NwaGgIj1a9A7MkwpBxM6RwACazHYJZxH1V+1B5dw5ciojuzs+x885KDP/Qh8eePoB3G0+hq/s8ent62L5K5I1tJMwtddUmKYBAIID91R/D4XbgpZcPIEyV3kUBpRCgsWgA2+UIFkJR7MpxIduThZgiofGV1/FI9VPI3+ZCjtulHgXHE3ECgKQx4HBQDZn0Ykd2DkZDIooyLch0K/D5w7jNZoYjFsF4/48403QCf7Y3o/bBPZgb6cH5k8fgou/C+lRevXuWk3qAJ/0z40f/rB0FGUYcf7IczZ/2YoLKrX8+iJ62M7joD2KP24K/L/fBmeGBNTyLW2/xQLJtR82Lr2kpmJoHGEBOphtTaSF8deoFFOWmY7zvfXzRcBjDnzXiN28fKnflQYjOI9OTjsDsBNVcCX0DY1STYmoNYB3Xog15gBf7RoeQV1Ck6vF6vbDb7cjNzVXvAJzrr77xFuaGvQgHpiErBqQ7HdhZWIhnj/G1cZH0YmBDAERRXP7casrWt3zWraffxh+Xuqn8yrir7F4cqq5VA1CbmzIATcFWWz0ASbNgq0aTrf//AaipqYHf71/eGPe3Qil5wO12L9tsaWnhS+hyf7NCSgDWG+F/glRpQ2mYqvL16/6TWaDnAb4j8FfrRhDfthf/526E9lR0/gs8uBE8u4t8mgAAAABJRU5ErkJggg==";

            APCache.AddIcon(nullKey, nullIcon);
            return(nullKey);
        }
Beispiel #2
0
        public static string GetIconID(string assetPath, bool isAnimation = false)
        {
            if (isAnimation)
            {
                var iconData1 = "iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAKoElEQVR4AeVba2+UxxU+ezX2rh17fceAGxOXIlDaVBWiEl+a0pakalUXgQC1FPGhUvkF/QF86C8AqRJfqFSpUqRIUf9EW0Ta0rRuSLBjO9h4zdp7v3gvPc959+zO4r3Ma3BY14NmZ3beeWfOec5zzlzWeCqVCh3k5D3IykP3Aw+A34YBHo+nh/sN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BJuYTnpJN0Gwm7lsgYAa/huKObGgq+iLwzjxjiuAOh2EFR585TZCVRbAHIVMICzgtBp4NfxHABA+eqWLWcjg0d9p11nHhh/knGSc6Rdvy56hgPFf1i3551kagpAEx/al/9zlJVv+J+jzYxtCwCABAi4o9gPCfdmDcpD6GYA2MYAvL9jQDTu9/Q/Fx0+MU9jgzEAAAAASUVORK5CYII=";
                var key1      = Utility.MD5(iconData1);
                APCache.AddIcon(key1, iconData1);
                return(key1);
            }
            try
            {
                var texture = AssetDatabase.GetCachedIcon(assetPath);

                if (texture == null)
                {
                    return(GetNullKey());
                }

                var format = (texture as Texture2D).format;

                if (!IsSupportedFormat(format))
                {
                    return(GetNullKey());
                }

                var newTexture = new Texture2D(texture.width, texture.height, (texture as Texture2D).format, false);
                newTexture.LoadRawTextureData((texture as Texture2D).GetRawTextureData());

                // Thanks Axel Garcia for fixing the read icon texture exception.
                //
                var bytes = new byte[0];
                try
                {
                    bytes = newTexture.EncodeToPNG();
                }
                catch (Exception e)
                {
                    Debug.Log(string.Format("Get Icon of {0} failed\r\n Exception: \r\n {1}", assetPath, e));
                    return(GetNullKey());
                }

                if (bytes != null && bytes.Length > 0)
                {
                    var iconData = System.Convert.ToBase64String(newTexture.EncodeToPNG());
                    var key      = Utility.MD5(iconData);
                    APCache.AddIcon(key, iconData);
                    return(key);
                }
                else
                {
                    return(GetNullKey());
                }
            }
            catch
            {
                return(GetNullKey());
            }
        }