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 Jaimse Jorms · Mar 30, 2010 at 05:57 AM · texturemeshmaterial

Apply material to imported mesh

I'm trying to put a material onto a mesh that I've imported from a .obj, but instead of the texture showing up, it shows a solid color that approximates the average hue of the texture.

I can instantiate a cube from the GameObject menu, then drag the material onto it in the Hierarchy view and it shows up as expected, but if I drag my mesh from the project view onto the hierarchy view, then drag the material onto it, I only get a solid color.

In case this is a strange way of doing things, I should probably also point out that I want to change the textures during the course of the game, so I don't want to apply them in the 3d app.

Comment
Add comment
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

3 Replies

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

Answer by Eric5h5 · Mar 30, 2010 at 07:45 AM

You need to UV map your objects. Without UV mapping, the hardware has no way of knowing how to apply the texture, so you just get a solid color. The built-in cube is UV mapped.

Comment
Add comment · Show 3 · 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 straydogstrut · Mar 30, 2010 at 10:41 AM 0
Share

Of course! $$anonymous$$icking myself now, I should've thought of that. Thanks.

avatar image Jaimse Jorms · Mar 30, 2010 at 08:28 PM 0
Share

Facepalm I knew it should be something simple. Thanks also straydogstrut for your example of using material objects.

avatar image edoz12 · Mar 06, 2014 at 12:03 AM 0
Share

I know it's an old post, but could someone explain me what the hell do you do to UV map your object? I've been searching for hours and none of the documentation I checked explained what to do.

avatar image
1

Answer by straydogstrut · Mar 30, 2010 at 06:56 AM

Hi Jaimse,

I don't use .obj much, but I threw one I had lying around into Unity and applied a texture no problem. The normal workflow is to create a material first, unless you already have one from your 3d app, then set its texture and apply the material to the mesh. Don't confuse materials and textures. Materials define how your object looks through properties such as color, texture and which shader you're using. However, Unity usually creates a material for you if you don't have one when you apply a texture straight to an object, so I don't see how you would have problems. Do you see a material in the Project View?

As for changing textures at runtime, look up renderer.material.mainTexture. The following assigns a texture to the object this script is attached to when it is initialised (myTexture being the texture you've chosen in the Editor):

var myTexture: Texture2D;

function Start(){

 renderer.material.mainTexture = myTexture;

}

See the Docs: http://unity3d.com/support/documentation/ScriptReference/Material-mainTexture.html

While the following assigns a texture through code that is stored in the resources folder (example from the Docs):

// Assigns a texture named "Assets/Resources/glass" to a Plane.
function Start () {
    var go = new GameObject.CreatePrimitive(PrimitiveType.Plane);
    go.renderer.material.mainTexture = Resources.Load("glass");
}

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

Hope that helps, sorry I don't have an answer for why your texture isn't showing up.

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
avatar image
0

Answer by krstrobe · Nov 30, 2015 at 06:46 PM

Sometimes when you haven't UV Mapped, the tiling being at 1 is too big. Take it way crazy down, like .01 or .001 and you may be able to see it.

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

2 People are following this question.

avatar image avatar image

Related Questions

2 Textures on a single mesh 1 Answer

Weird shine (gloss?) when far from object 0 Answers

Not sure how to change mesh materials in code 1 Answer

How can I convert a "grid" of textured quads to a single mesh? 0 Answers

Fix uneven application of a texture/material 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