Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by arcandio · Jun 04, 2020 at 07:52 PM · importeditor-scriptingimporting problemstextureimporterimport settings

AssetDatabase.ImportAsset fails on generated textures

I'm trying to generate a number of PNG icons from 3d objects in Unity. Generating and saving the images works fine, but I can't seem to finish the process of saving the new assets to the database. When I attempt to use AssetDatabase.ImportAsset(), it fails with the following error:

 Could not create asset from Assets/Artwork/Resources/Icons/Insertions/Carnation - Light Blue.png: Texture could not be created.
 UnityEditor.AssetDatabase:ImportAsset(String, ImportAssetOptions)
 Editor.IconGenerator:SaveTextureToPNG(String, Texture2D) (at Assets/Code/Editor/IconGenerator.cs:95)
 Editor.IconGenerator:GenerateInsertionIcons() (at Assets/Code/Editor/IconGenerator.cs:38)
 Editor.IconGenerator:GenerateAllIcons() (at Assets/Code/Editor/IconGenerator.cs:17)


That path is directly from a previous reference to the asset, so I don't understand why it fails. When I check in the inspector, the new assets exist, and the settings are actually changed, but they haven't been applied.

Here's a snippet of the larger script:

 TextureImporterSettings settings = new TextureImporterSettings();
 settings.alphaIsTransparency = true;
 settings.alphaSource = TextureImporterAlphaSource.FromInput;
 settings.sRGBTexture = true;
 textureImporter.SetTextureSettings(settings);
 EditorUtility.SetDirty(textureImporter);
 AssetDatabase.ImportAsset(path, ImportAssetOptions.ForceUpdate);
Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Forberg · Mar 14, 2021 at 01:24 PM 0
Share

Did you resolve this? Having the same issue. I suspect an incomplete assignment of the texture importer settings as I did not have any problems when editing the texture importer directly.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by AtheMathmo · Jun 04, 2021 at 06:37 PM

@Forberg is right! You need to initialize the rest of the settings in the TextureImportSettings object. The easiest way I found to do this was to first use: textureImporter.ReadTextureSettings(settings);, then you can make your changes, and set it again.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

151 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Override texture import path 0 Answers

Creating a complex prefab during asset postprocessing 1 Answer

change textures without changing the original file 0 Answers

Importing Quick Smoke From Blender 1 Answer

Unity doesn't import animations from Blender and causes other problems 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges