Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 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
16
Question by damiant · Mar 06, 2013 at 04:52 AM · editormaterialinspector

Change the color of a material for only one object

Is it possible to change the color of an object's material using the editor without changing the color of all other objects using that material?
I mean, using the editor, not via scripting.

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

7 Replies

· Add your reply
  • Sort: 
avatar image
31

Answer by monotoan · Mar 24, 2017 at 12:19 PM

A form of this is possible now using Unity's sparsely-documented but extremely useful "Material Property Block" feature.

You will have to write a script to set yourself up to use this feature, but once that script's written, you can add it to objects and then set their specific color through a color-picker in the component inspector / editor window, much like you would on a material.

Here's a good introduction to this feature: http://thomasmountainborn.com/2016/05/25/materialpropertyblocks/

And here's the official documentation, such as it is: https://docs.unity3d.com/ScriptReference/MaterialPropertyBlock.html

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 brussow92 · Sep 04, 2017 at 11:31 AM 0
Share

That is working perfectly and exactly what i was looking for. Thanks monotoan.

avatar image chimeforest · Oct 18, 2017 at 07:15 AM 0
Share

This is exactly what I needed, Thank you! =D

avatar image defyngames · Mar 09, 2019 at 07:56 AM -1
Share

Holy cow, thanks mann!

avatar image
8

Answer by Eric5h5 · Mar 06, 2013 at 05:38 AM

No, the color is part of the material, so if you change the color, any object using that material will have the color changed. Technically it's not possible to do in code either; you get the illusion that you can, because Unity creates a copy of the material for you behind the scenes (which can cause issues in certain circumstances, so I'm not sure that was the best design choice). So anyway, if you want two objects to have two different colors, you need two different materials.

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
3

Answer by metalvblue · Jul 30, 2019 at 07:46 PM

Best way is to : this.gameObject.GetComponent().material = Instantiate(Resources.Load("Material") as Material);

This way it becomes an instance material during runtime therefore seperate and unique only to that gameobject, then you can just change the tint color or color for example:

this.gameObject.GetComponent().material.color = Color.cyan;

or

this.gameObject.GetComponent().material.SetColor("_TintColor", Color.green);

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 DrRocker87 · Aug 13, 2020 at 02:03 AM 0
Share

Yessssss, totally forgot about this. Lifesaver! Also, if you prefab something and want to keep the prefab instance in tact, this is clearly the best answer!

avatar image
1

Answer by paranoidray · Dec 02, 2015 at 09:47 AM

The best way to do this is to copy the existing Material ( Ctrl-D ) and then change the color on that new Material.

And then in the code or in PlayMaker you can assign the new Material, that works much better and leaves other instances alone.

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
-2

Answer by pixels3d · Oct 09, 2013 at 12:32 PM

you attach a script to your game object, you create a public color variable, then in your update or start method you write this gameObject.renderer.material.color = your_color_variable ;

unity3diy

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
  • 1
  • 2
  • ›

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

24 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

Related Questions

How to set a shared material in inspector? 0 Answers

Edit chosen material in the inspector for custom editor. 2 Answers

What does the second button in Material Preview do? 1 Answer

Material instantiation problem 1 Answer

GameObject position not matching up to its position in the inspector even though they are clearly linked [answered] 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