|
Greetings, I have been working for along time, to figure out how to add multiple materials, to an object through scripting. Example; I have an object, cube, and its green from its material! I want to make it so that when I click it there is an new material added to it, whit an transparenty texture, so that has yellow edges! But it doesnt stop here, I also want another material over that again, so it makes it have red circle in the middle, again, transparenty texture! I know how to script the code to check when I am clicking it, I just use "OnMouseUp", put, how can I be able to add multiple materials through that script? It would be much appreciated if someone could lend me, a hand! Thanks in advance! Best Regards, M!
(comments are locked)
|
MatChanger.csusing UnityEngine;
using System.Collections;
public class MatChanger : MonoBehaviour
{
public Material[] Materials;
void OnMouseUp()
{
renderer.material = Materials[UnityEngine.Random.Range(0, Materials.Length)];
}
}
(comments are locked)
|
