Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
0
Question by Johan 4 · Jun 15, 2011 at 09:07 PM · editormeshimportsettings

Change an object's import settings in the editor

I got a mesh that I need to change the settings for. I found http://unity3d.com/support/documentation/ScriptReference/ModelImporter.html But I can't figure out how to use it. What I want is to simply do something like:

Mesh mesh; mesh.thisorthat = value;

from the editor. The model importer seems perfect for that, but I can't figure out how to assign a mesh to it.

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 hamokshaelzaki · Jun 15, 2013 at 05:31 AM 0
Share

I don't know a way for this, but what I know is: You can replace the texture -that will be loaded in the run-time- in the Assets folder and set the settings as you want, in the run-time when you load it, it'll be loaded with the settings you just saved.

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by jahroy · Jun 15, 2011 at 09:42 PM

It sounds like you might be interested in writing an editor script.

You could write a function that gets invoked by a menu item that could do what you want.

One easy way to do it would be to use the Selection object, which allows you to select an object in the project or hierarchy and perform operations on it.

Selection:

http://unity3d.com/support/documentation/ScriptReference/Selection.html

MenuItem (with some nice example code):

http://unity3d.com/support/documentation/ScriptReference/MenuItem.html

Another way to reference an object from an editor script is to use the AssetDatabase or Resources classes.

AssetDatabase (allows you to load an asset based on its path among other things):

http://unity3d.com/support/documentation/ScriptReference/AssetDatabase.html

Resources (allows you to load assets from specific directories at runtime):

http://unity3d.com/support/documentation/ScriptReference/Resources.html

If you're talking about changing settings when assets are imported, you might want to look at the AssetPostprocessor class, which lets you specify various functions to get executed whenever various types of assets get imported:

http://unity3d.com/support/documentation/ScriptReference/AssetPostprocessor.html

Comment
Add comment · Show 2 · 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
avatar image Johan 4 · Jun 16, 2011 at 10:22 AM 0
Share

Yeah I am referencing my objects right now and that works, I can change the limited amount of options that mesh object has. But I need to change it's import properties. Like I reference it and then change import properties of it and then apply it or something.

avatar image jahroy · Jun 16, 2011 at 10:38 PM 0
Share

Here's some code I use to override image import settings for iOS builds.

It gets called from a $$anonymous$$enuItem in an editor script.

It's basically copied directly from the wiki:

   static void SelectedChangeTextureFormatSettingsIOS(TextureImporterFormat newFormat) 
     {
    
         Object[] textures = GetSelectedTextures();
         Selection.objects = new Object[0];
         foreach (Texture2D texture in textures)  {
             string path = AssetDatabase.GetAssetPath(texture);
             TextureImporter textureImporter = AssetImporter.GetAtPath(path) as TextureImporter;
             textureImporter.SetPlatformTextureSettings("iPhone", 1024, newFormat);
             AssetDatabase.ImportAsset(path);
         }
     }

It looks like using a $$anonymous$$odelImporter would be pretty similar.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Updating UV in imported mesh without having to re-material 0 Answers

How to Change Default Import Settings? 5 Answers

When to use Generate Lightmap UV? 0 Answers

Mesh import setting - scale factor = 0.01 default, why? 0 Answers

Rename Mesh -- editor script ? 2 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