Search Unity

Question Customize PSD Importer

Discussion in 'Scripting' started by od3098, Nov 29, 2020.

  1. od3098

    od3098

    Joined:
    Apr 29, 2015
    Posts:
    56
    I am trying to write an AssetPostprocessor to change imported PSB file settings after they are imported.
    the problem is for normal textutes, AssetImporter will return a TextureImporter type and we can change settings. but for PSB files, AssetImporter returns PSDImporter type and there are no methods to change settings.
    I need to set pivot to center, disable generating mipmap and enable Use crunch compres for all my psb files and could not find my answer in official documentation or in similar questions.
    Any hints or tips are highly appreciated.

    Code (CSharp):
    1.  
    2. public class PSBPostImport : AssetPostprocessor
    3. {
    4.     void OnPostprocessTexture(Texture2D texture)
    5.     {
    6.         var ext = Path.GetExtension(assetPath);
    7.         if (ext == ".psb")
    8.         {
    9.             AssetImporter importer = AssetImporter.GetAtPath(assetPath);
    10.             if (importer is PSDImporter psdImporter)
    11.             {
    12.                 // psdImporter has no usable properties or methods
    13.             }
    14.         }
    15.     }
    16. }
    17.  
    upload_2020-11-29_3-56-7.png
     
    Last edited: Nov 29, 2020
    tonytopper likes this.
  2. LorenzoNuvoletta

    LorenzoNuvoletta

    Joined:
    Apr 28, 2014
    Posts:
    54
    Interested in this as well
     
  3. Leo-Yaik

    Leo-Yaik

    Unity Technologies

    Joined:
    Aug 13, 2014
    Posts:
    436
    Hi, thanks for the feedback.
    We will look into exposing these settings via API.

    If you need to change all the textures, you can try using Presets and set them as default. This will allow future new files to have the same settings.
     
  4. Leo-Yaik

    Leo-Yaik

    Unity Technologies

    Joined:
    Aug 13, 2014
    Posts:
    436