Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
This question was closed Aug 19, 2014 at 03:40 PM by gjf for the following reason:

Solved myself; might be informative to others

avatar image
0
Question by gjf · Aug 19, 2014 at 11:39 AM · c#editorassetdatabase

inconsistent TextureImporter settings

i'm experiencing some inconsistencies between projects using the same code (an editor script to create textures) & assets.

the following code creates a TextureImporterSettings with various settings.

     var importSettings =  new TextureImporterSettings
         {
             npotScale = TextureImporterNPOTScale.None,
             readable = true,
             mipmapEnabled = false,
             wrapMode = TextureWrapMode.Clamp,
             filterMode = FilterMode.Point,
             maxTextureSize = 1024,
             textureFormat = TextureImporterFormat.AutomaticTruecolor
         };

     importSettings.ApplyTextureType(TextureImporterType.Advanced, true);

then i'm applying them to an asset that i've created using:

             if (savedFilename != "")
             {
                 AssetDatabase.Refresh();

                 var importer = AssetImporter.GetAtPath(savedFilename) as TextureImporter;

                 if (importer != null)
                 {
                     importer.SetTextureSettings(importSettings);
                     AssetDatabase.WriteImportSettingsIfDirty(savedFilename);
                 }
              }

this is only applied to successfully created textures.

inconsistencies arise when i copy the editor script that this code is from to a different project. in one, the texture is (correctly) shown with a type of 'Advanced' but, in another, the type is 'Sprite 2D \ uGUI'.

my only assumption is that by creating importSettings, is that they will be dirty, and therefore written.

any suggestions as to why this might be happening?

thanks in advance.

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 gjf · Aug 19, 2014 at 03:39 PM 0
Share

i've found a way to resolve the problem.

removing this line

 importSettings.ApplyTextureType(TextureImporterType.Advanced, true);

and then the code after the null check looks like

                 if (importer != null)
                 {
                     importer.textureType = TextureImporterType.Advanced;

                     importer.SetTextureSettings(importSettings);
                     AssetDatabase.WriteImportSettingsIfDirty(savedFilename);

                     AssetDatabase.ImportAsset(savedFilename);
                 }

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

21 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

Related Questions

Using Hidden folders for editor stuff? 1 Answer

Initialising List array for use in a custom Editor 1 Answer

Getting direct dependencies for an asset 1 Answer

How do I wait until after AssetDatabase creates an assets before carrying out another function ? 0 Answers

Help with Missing Monobehaviours and Asset Serialization? 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