Question by
VaiaIthilnaur · May 06, 2018 at 11:48 PM ·
unity 5lightingobjectlight
Changing lightning color on other object
public class PortalController : MonoBehaviour {
public GameObject Lightning;
void Update () {
if (Input.GetMouseButtonDown (0)) {
RaycastHit hit;
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
Light lt = GetComponent<Light> ();
if (Physics.Raycast(ray, out hit)) {
if (hit.transform.name == "PanelBlue" ){
Debug.Log ("BtnRightPressed");
lt.color = Color.blue;
}
else if (hit.transform.name == "PanelRed" ){
Debug.Log ("BtnRightPressed");
lt.color = Color.red;
}
}
}
} }
Comment
Answer by VaiaIthilnaur · May 06, 2018 at 11:51 PM
And .... It doesn't work This code might switch the lightning color when i press the button (button and the "public GameObject Lightning;" are different object) Can u help to solve this problem?
Your answer
Follow this Question
Related Questions
I have light problem in Unity 5.4.1f. Please help. 0 Answers
Object not casting shadow properly 1 Answer
Unity 2D - Material for light 2 Answers
Environment Lights 0 Answers
How to activate a script without runtime or press play button in Unity 0 Answers