Ejemplo n.º 1
0
        public override void OnPreviewGUI(Rect rect, GUIStyle background)
        {
            //original preview
            base.OnPreviewGUI(rect, background);

            Sprite sprite = target as Sprite;

            if (sprite == null)
            {
                return;
            }

            bool isTargetChanged = _oldSprite != sprite;

            _oldSprite = sprite;

            if (Selection.objects.Length <= SpriteAssistSettings.Settings.maxThumbnailPreviewCount)
            {
                if (isTargetChanged)
                {
                    string assetPath = AssetDatabase.GetAssetPath(sprite);
                    _dummySprite = SpriteUtil.CreateDummySprite(sprite, assetPath);
                    _textureInfo = new TextureInfo(_dummySprite, assetPath);
                }

                SpriteProcessor?.OnPreviewGUI(rect, sprite, _dummySprite, _textureInfo);
            }
        }
Ejemplo n.º 2
0
 private void Resize()
 {
     foreach (var selectedTarget in _targets)
     {
         if (SpriteImportData.TryGetSpriteImportData(selectedTarget, out var importData))
         {
             SpriteUtil.AddAlphaArea(importData.dummySprite, importData.assetPath);
         }
     }
 }
Ejemplo n.º 3
0
        public SpriteImportData(Sprite sprite, string assetPath)
        {
            this.sprite    = sprite;
            this.assetPath = assetPath;
            dummySprite    = SpriteUtil.CreateDummySprite(sprite, assetPath);

            textureImporter         = AssetImporter.GetAtPath(this.assetPath) as TextureImporter;
            textureImporterSettings = new TextureImporterSettings();
            textureImporter.ReadTextureSettings(textureImporterSettings);
            _oldSourceAssetIdentifier = new AssetImporter.SourceAssetIdentifier(typeof(GameObject), Path.GetFileNameWithoutExtension(assetPath));
            _newSourceAssetIdentifier = new AssetImporter.SourceAssetIdentifier(typeof(GameObject), MESH_PREFAB_IDENTIFIER);
        }
Ejemplo n.º 4
0
        public static bool TryGetSpriteImportData(Object obj, out SpriteImportData spriteImportData)
        {
            spriteImportData = null;

            Sprite sprite = SpriteUtil.FindSprite(obj);

            if (sprite == null)
            {
                return(false);
            }

            string          assetPath       = AssetDatabase.GetAssetPath(sprite);
            TextureImporter textureImporter = AssetImporter.GetAtPath(assetPath) as TextureImporter;

            if (textureImporter == null)
            {
                return(false);
            }

            spriteImportData = new SpriteImportData(sprite, textureImporter, assetPath);
            return(spriteImportData != null);
        }