- Home /
Change material GameObject locally
Hi everyone,
I have a question, I'd like to change the material of a GameObject, but locally. But I wonder how it is possible to change locally (following the mouse for example) the material (like a spray of a painting)? This code changes totally the material :
public class Painting : MonoBehaviour {
public GameObject plan;
void Update () {
if (Input.GetMouseButtonDown(1)) {
planPeinture.renderer.material.color = Color.red;
}
}
}
I hope I am clear enough. Thanks in advance!
your code will change the color or your material, what you want to do? would you like to change this material by another material that you have?
Hi I just want to change partially the color of my GameObject (like painting with a spray on the object). I don't know what is a Decal system, could you be more specific?
Hi,
I just want to change partially the color of my object (like using a spray of painting on the object).
Ironically, that second comment could have been an edit. :)
Answer by YM_Industries · Dec 01, 2012 at 12:14 PM
It looks like you're looking for a decal system.
There are several ways you can go about implementing this:
If you're willing to get your hands a bit dirty, you can make your own system. The accepted answer on this question provides a useful starting place.
If you just want an off the shelf package, this asset package looks promising.
If you need any more help, feel free to ask me. It's also worth noting that I haven't tested either of the above solutions, so YMMV.
Your answer
Follow this Question
Related Questions
Change the material on an Object in a script? 2 Answers
How to change material of gameobject using C# to a material asset. 2 Answers
Player Material Change works on shop preview menu, does not change Player material on other scenes. 0 Answers
Changing gameObjects material on trigger? 1 Answer
Adding Decal to Tessellated Material 0 Answers