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 /
avatar image
1
Question by r.daneel · Nov 06, 2014 at 10:26 AM · editorgraphics

How to change the texture of a prefab

I am new to Unity. very new. I just downloaded Unity and I have a sample package loaded. The game has a number of prefabs, and I want to change the texture of one of them. For example, the game has an object that appears in various scenes - let's say a box. The box is a woodgrain texture, but I want it to be a steel box. I can see the texture png file for the prefab. I can see the prefab file and meta file.

What do I need to do to just change the texture of that prefab so that every time an object instantiated from the prefab appears, it appears with the new texture?

Comment
Add comment · Show 3
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 AlwaysSunny · Nov 06, 2014 at 11:09 AM 0
Share

Please consider spending time in the Learn area of the website prior to asking questions. Lots of beginner's information can be found there with ease.

avatar image MrSoad · Nov 08, 2014 at 02:46 AM 0
Share

You can drag the material you want onto the object in the scene, you can then drag the newly textured object(from the hierarchy window) onto the original prefab.

If you only have textures then this will still work but it will give it a std diffuse shader, which you will probably want to change.

Or you can look at the texture file in the material on the prefab, you can then click on it and pick one from the list that appears.

There are so many ways to do this :D

Look up shaders and materials and do a little bit of searching, reading and learning like Sunny says. This is very basic stuff.

avatar image CGphantom · Feb 12, 2017 at 09:10 AM 0
Share

I'm not all that new to unity and I still run into problems with this prefab material stuff. Its poorly engineered and even a beginner should not get lost in the process. It should be as simple as editing materials to desired result > pushing an update prefab with material button.... done. end of story. Having a wonderful time trying to accomplish what should be a very straight forward task right now, and its drivin g me mad.

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by fddefdef · Nov 06, 2014 at 11:10 AM

Hi r.daneel,

to do what you want you just have to change the material of the prefab from its renderer component (in most cases the mesh renderer component). Once you changed it, all the game objects you'll instanstiate from that prefab will have that material (and the texture attached to that material).

Comment
Add comment · Show 1 · 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 r.daneel · Nov 08, 2014 at 02:30 AM 0
Share

Thanks for answering. I must be missing something. I navigate to Assets->Prefabs in the Project view and I see the Prefab I want to change. I drag it into the Scene panel, select it, and it's attributes appear in the Inspector. I can see the $$anonymous$$esh Renderer, but that's where I get lots. What I want to do is replace the .png file that is being used as the texture to a different .png file, and therefore a new texture. How do I do that?

avatar image
0

Answer by NaRango4 · Nov 06, 2014 at 11:08 AM

textures are linked to materials. you need to modify materials.

there should be a "Mesh Renderer" component which contains material associated with it. You should be able to modify here

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 mohit.parihar · Nov 08, 2014 at 06:15 AM

hi,

 Texture2D tempTexture = (Texture2D)Resources.Load("Image_name")as Texture2D;
 obj.renderer.material.mainTexture=tempTexture;

 obj is your game object.
Comment
Add comment · Show 1 · 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 MrSoad · Nov 08, 2014 at 01:12 PM 0
Share

You might want to re-read the question a bit, good answer just not the answer to the question.

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

8 People are following this question.

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

Related Questions

Set Graphics Emulation to No Emulation as Default? 2 Answers

UI Elements keep loosing graphic properties, textures aren't visible or outlines only 0 Answers

Unity Editor in extremely low graphics quality 1 Answer

Colldier wireframe and navmesh overlay not showing. 0 Answers

Allow shaders with 'time' variable to update in editor 1 Answer


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