Question by
Anonymou5 · Sep 27, 2016 at 06:46 PM ·
c#scripting problembuttonvehicletoggle button
Script don't work if connected to vehicle
I have script to turn vehicle lights on / off when i click cube. But i don't work if it is connected to vehicle.
Does anyone have ideas how i can connect it to vehicle? Or is there something wrong with my script?
using UnityEngine;
using System.Collections;
public class ToggleLightButton : MonoBehaviour
{
bool isOn;
public Light[] Light;
public void OnMouseDown()
{
isOn = !isOn;
if (isOn)
{
GetComponent<Renderer>().material.color = Color.white;
Light[0].enabled = false;
Light[1].enabled = false;
}
else
{
GetComponent<Renderer>().material.color = Color.red;
Light[0].enabled = true;
Light[1].enabled = true;
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Script loads wrong information 0 Answers
Disable or hide GUI Buttons on one scene 2 Answers
Problem with enabling menu 0 Answers
UI buttons won't recognize script 0 Answers