- Home /
Shared materials over muliple players
Hello,
I have tried to set different colors, textures or materials over multiple players, but I can't find the solution.
I want different players to shared a list of materials without having the same aspect (color and such) at runtime.
Do you know what's the procedure to do so ?
I don't think this is possible... Why don't you just make one $$anonymous$$aterial for every Player?
Answer by SaurabhStudio · Mar 09, 2016 at 07:19 PM
hello @Gvrv You can add script to set color individual, If you have instantiate gameobject
With help of
gameObject.renderer.material.color = Color(0.777, 08, 0.604);
or
gameObject.renderer.material.color = Color.white;
This will not change color of prefab.
Thank you !
It works.
Use this :
foreach (var col in gameObject.GetComponentsInChildren<Renderer>())
{
col.material.color = Random.ColorHSV();
}
To randomly pick a color
Answer by Cheeseless · Mar 09, 2016 at 07:17 PM
By no means do I know much about sharing components, but have you looked at http://docs.unity3d.com/ScriptReference/Material.CopyPropertiesFromMaterial.html ? You could probably use that and just have a script that'll copy the material off a "master" Player, and attach it to each actual player, then copy over everything. Then you can use stuff like SetColor and such to change them if you need to.