This is more for me understanding how to do this than an actual need. I have two objects in game. Object1 and Object2. Object2 would like to set a variable on Object1 to true.
GetComponent reference isn’t helping (maybe it’s out of date)
Object1 has the following script
test1.cs
public bool changeMe;
void Start()
{
changeMe = true;
}
void Update()
{
Debug.Log("changeMe is equal to " + changeMe);
}
Object2
test2.cs
public GameObject object1Transform;
//Going to try and set object1 from true to false from here.
void OnGUI()
{
if(GUI.Button(new Rect(10,10,100, 40), "Change That Bool!"))
{
script = object1transform.GetComponent<test1>();
script.changeMe = false;
}
}