Hello i have a problem with my button prefab.
Im having diferent buttons all over my game, and its importent that i know if they are on or off. The button script where its turned on or off is in one script (Script A) where the activation of that scripts is in my player script (Script B).
So I need Script B to trigger a function on Script B. Pretty simple i got that to work, but its doing it on all the prefabs when im doing it this way.
Can someone write some code or explane how im changing my Boolean on onely one object insted of all the prefabs.
The button comes from a prefab with a script.
Thanks for your time reading this question.
Edit:
Sorry for that, this is my fist question and not sure how to set it up i will give some code here:
Script B
var UseScript : GameObject;
//*Public Variables End*
function Update ()
{
if((Input.GetKeyDown(controllsUse) && inUseRange) || (Input.GetKeyDown(controllsUse2) && inUseRange))
{
Use();
}
}
function Use()
{
print("use");
UseScript.GetComponent(JsObjectsButtons).UseButton();
}
function OnTriggerEnter (other : Collider)
{
if (other.tag == "Button")
{
print("In");
inUseRange = true;
}
}
function OnTriggerExit (other : Collider)
{
if (other.tag == "Button")
{
print("Out");
inUseRange = false;
}
}
**Script A**
//useable Objects
//Public Variables
var objKind : int;
//Private Variables
var isOn : boolean = false;
function Update ()
{
UseButton();
}
public function UseButton()
{
if(isOn)
{
isOn = false;
renderer.material.color = Color.blue;
}
else if(!isOn)
{
isOn = true;
renderer.material.color = Color.green;
}
print(isOn);
}