public class First : MonoBehaviour {
public GameObject secondClass;
public Vector3 pos;
void Update () {
if (Input.GetKey(KeyCode.Space) )
{
Instantiate(secondClass, pos, Quaternion.identity);
Debug.Log(secondClass.GetComponent<Second>().open); //this will print false,WHY?
//Is the “Instantiate” problem?
}
}
}
public class Second : MonoBehaviour {
public bool open;
void Start (){ open = false; }
void Update (){
int a = 1;
if(a == 1)
{
open = true;
Debug.Log(open); //this will print true
}