Question by
umaradil · Jul 19, 2019 at 11:16 AM ·
unityeditormaterialscomponents
how to get component of array in unity
hello in my game am using an array and storing gameobjects with ("blue_f") tags in it
GameObject[] Blue;
public Material[] material;
public void Start(){
{
Blue = GameObject.FindGameObjectsWithTag("blue_f");
}
and then in update am assigning them material
public void Update(){
foreach (GameObject gone in Blue)
{
gone.GetComponent<Renderer>().material = material[0];
}
i want enable emission of every when my player trigger with it
public void OntriggerEnter(Collider other){
if (other.gameObject.CompareTag("blue_f") || (other.gameObject.CompareTag("pink_f")))
{
foreach(GameObject go in Blue)
{
go.GetComponent<Renderer>().material.EnableKeyword("_EMISSION");
}
}
it is enabling emission of all objects with ("blue_f") tag i want to enable emission of only object with player will trigger
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612205139im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Javascript Help 0 Answers
Missing Materials 2 Answers
Filling regions of a texture before projecting 0 Answers
Error building Player: CommandInvokationFailure: Failed to re-package resources. 0 Answers
can I Cutoff/Blackscreen part of the unity camera screen? 0 Answers