Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question TextureImporterFormat.RGBAFloat Invalid for All Types?

Discussion in 'General Graphics' started by Ikaroon, Nov 30, 2023.

  1. Ikaroon

    Ikaroon

    Joined:
    Jun 19, 2016
    Posts:
    31
    Hey everyone,

    I need to import a texture as RGBAFloat but I always get the error that the texture format is incompatible with the selected texture type.
    I wonder why this TextureImporterFormat is even available if it is incompatible with all texture types.

    My importer:
    Code (CSharp):
    1. public class GlintTextureImporter : AssetPostprocessor
    2. {
    3.     public void OnPreprocessTexture()
    4.     {
    5.         if (!(assetImporter is TextureImporter textureImporter))
    6.             return;
    7.  
    8.         var labels = AssetDatabase.GetLabels(assetImporter);
    9.  
    10.         if (labels.Contains("GlintMap"))
    11.         {
    12.             textureImporter.textureType = TextureImporterType.Default;
    13.             textureImporter.textureCompression = TextureImporterCompression.Uncompressed;
    14.             textureImporter.mipmapEnabled = false;
    15.             textureImporter.sRGBTexture = false;
    16.             textureImporter.wrapMode = TextureWrapMode.Repeat;
    17.             textureImporter.filterMode = FilterMode.Point;
    18.  
    19.             var settings = textureImporter.GetDefaultPlatformTextureSettings();
    20.             settings.textureCompression = TextureImporterCompression.Uncompressed;
    21.             settings.format = TextureImporterFormat.RGBAFloat;
    22.             textureImporter.SetPlatformTextureSettings(settings);
    23.         }
    24.     }
    25. }
    Any help would be greatly appreciated!