Search Unity

Help Wanted Custom Texture importer prevents manual changes

Discussion in 'Testing & Automation' started by Noblauch, Jun 19, 2020.

  1. Noblauch

    Noblauch

    Joined:
    May 23, 2017
    Posts:
    254
    I'm using the AssetPostprocessor to make the default import type for images "Sprite". But now I realized it prevents me from ever changing the texture type manually of any images.
    Code (CSharp):
    1. using UnityEditor;
    2. using UnityEngine;
    3.  
    4. public class CustomImportSettings : AssetPostprocessor
    5. {
    6.     private TextureImporterType importType = TextureImporterType.Sprite;
    7.  
    8.     private void OnPostprocessTexture(Texture2D texture)
    9.     {
    10.         TextureImporter importer = (TextureImporter)assetImporter;
    11.         importer.textureType = importType;
    12.     }
    13. }
    What should I do? >.<
     
  2. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,486
    Take a look at the new Presets feature, which includes the ability to control the default import settings for assets.
     
  3. Noblauch

    Noblauch

    Joined:
    May 23, 2017
    Posts:
    254
    Seems like this doesn't work with reimports. If I have a folder that needs to be converted to the new default import settings. But I managed to get it to work for newly added assets. I'm going to stick with it until I run into problems.
     
unityunity