Note that there are some explanatory texts on larger screens.

plurals
  1. POunable to change color of point light after instantiating in prefab
    text
    copied!<p>I have a prefab for a point light to produce a glow around a sphere. Based on the "type" (health, personality, talent) the color of the glow has to change. Here's my code to do that - </p> <pre><code>GameObject glow = (GameObject)Instantiate(glowPrefab,new Vector3(0,0,0),Quaternion.identity); glow.transform.parent = child.transform; glow.transform.localPosition = new Vector3(0,0,0); switch(type) { case "health": child.renderer.material = health; glow.GetComponent&lt;Light&gt;().color = new Color(254f,137f,96f,255f); //Debug.Log ("Health Color" + glow.light.color ); break; case "personality": child.renderer.material = personality; glow.GetComponent&lt;Light&gt;().color = new Color(137f,254f,96f,255f); //Debug.Log ("Personality Color" + glow.GetComponent&lt;Light&gt;().color ); break; case "talent": child.renderer.material = talent; glow.GetComponent&lt;Light&gt;().color = new Color(137f,96f,254f,255f); //Debug.Log ("Talent Color" + glow.GetComponent&lt;Light&gt;().color ); break; } </code></pre> <p>Although the debug.log shows that the light has changed, in the game, it is still white. What's funny is that, when it is run, the scene shows multicolored lights - </p> <p><img src="https://i.stack.imgur.com/x39Sp.png" alt="enter image description here"></p> <p>But, in the game, the color is white - </p> <p><img src="https://i.stack.imgur.com/2VcWy.png" alt="enter image description here"></p> <p>When I click on an individual light, the color is white - </p> <p><img src="https://i.stack.imgur.com/Z4e7w.png" alt="enter image description here"></p> <p>Even if I change the prefab color, the color of the lights is still white. </p> <p><img src="https://i.stack.imgur.com/YDsD8.png" alt="enter image description here"></p> <p>How do I check where the color is being changed? Is there an event I can use for logging?</p> <p>Thanks! </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload