Hey everyone.
I used this line here:
renderer.material.SetColor("_Color", meshColor);
To make it possible to change the color of an instance without having to create a material for it.
The problem the artists have with it is that it’s only showing up in game.
How can I make it show up in the editor like that? is there any way?
thanks!
Add:
@script ExecuteInEditMode() if your using JavaScript
or
[ExecuteInEditMode] if your using C#
At the top of your script.
Thank you so much Dman!
It now sees it as instances. The problem is, that it first worked, but after applying some changes to the prefab, the all turned back to default, which is ok, but when I tried to give them all different colors again, the all change like before…
[ExecuteInEditMode]
public class Color : MonoBehaviour {
private Color meshColor;
void Awake () {
meshColor = renderer.sharedMaterial.GetColor("_Color");
}
What is happening?
For some reason I have to apply a different color, on startup of the game, to the mesh. Then it will see it as a different instance, after that we can change it in editor.
I just want to be able to duplicate an object and then change the color from the material, without it changing the previous prefab.
Is there any way to do this?
To the best of my knowledge you’ll have to write an editor extension that duplicates an object as well as it’s material so that you can alter the material on the duplicate without altering the material of the original.
Or you can just manually duplicate the prefab, find it’s material - duplicate that material, drag the duplicate onto the new prefab. Without duplicating the material as well though, both of your prefabs will be sharing that material - so any changes made to one will apply to both (unless you use renderer.material at runtime which creates a temporary copy, but this is really meant for runtime use).
To write a quick editor script you should be able to use:
To get the asset path of the material on your original prefab. And…
To duplicate that material.