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.
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:
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.
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);
You should create the object in run time. So engine would create an instance material for the new object. You could change the color of instance material.
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.
mabye you are using one material in for eg 5 cubes so obiously alll the cubes color will change right
-sorry for my horribal spelling