I am new to both unity3D and C#. After creating my first “Hello world” program, I have a question about the public class object in script.
In the level, I have two game objects (A & B). There are two scripts attached to these objects separately. The script A is as follows:
public class ScriptA : MonoBehaviour
{
public int m_value1;
public int m_value2;
public int m_value3;
// Use this for initialization
void Start()
{
m_value1 = 0;
m_value2 = 0;
m_value3 = 0;
}
}
and the script B is:
public class ScriptB : MonoBehaviour {
public ScriptA m_objectA;
public int m_value1 = 0;
public int m_value2 = 0;
}
I am now wondering that whether the m_objectA in scriptB only a reference of object A or the data of object A is stored in two places in my memory. I am really worried about this problem especially when I want to use object A to store enormous data. Thanks a lot!