Exemple #1
0
        public override Texture2D RenderStaticPreview(string assetPath, UnityEngine.Object[] subAssets, int width, int height)
        {
            SpriteAtlas spriteAtlas = AssetDatabase.LoadMainAssetAtPath(assetPath) as SpriteAtlas;
            Texture2D   result;

            if (spriteAtlas == null)
            {
                result = null;
            }
            else
            {
                Texture2D[] previewTextures = spriteAtlas.GetPreviewTextures();
                if (previewTextures == null || previewTextures.Length == 0)
                {
                    result = null;
                }
                else
                {
                    Texture2D texture2D = previewTextures[0];
                    PreviewHelpers.AdjustWidthAndHeightForStaticPreview(texture2D.width, texture2D.height, ref width, ref height);
                    result = SpriteUtility.CreateTemporaryDuplicate(texture2D, width, height);
                }
            }
            return(result);
        }
        public override Texture2D RenderStaticPreview(string assetPath, Object[] subAssets, int width, int height)
        {
            var spriteAtlas = AssetDatabase.LoadMainAssetAtPath(assetPath) as SpriteAtlas;

            if (spriteAtlas == null)
            {
                return(null);
            }

            var previewTextures = spriteAtlas.GetPreviewTextures();

            if (previewTextures == null || previewTextures.Length == 0)
            {
                return(null);
            }

            var texture = previewTextures[0];

            PreviewHelpers.AdjustWidthAndHeightForStaticPreview(texture.width, texture.height, ref width, ref height);

            return(SpriteUtility.CreateTemporaryDuplicate(texture, width, height));
        }