using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Room : MonoBehaviour {
public ClassB classBTestInstance = new ClassB(3);
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
}
public class ClassB {
public ClassB(int testNum) {
Debug.Log("hello " + testNum);
}
}
and here is the output:
As you can see that it says "Hello 3" twice. I wish to understand why might that be the case? I don't see where I called it twice. In image2 you will see that there is only 1 instance of room (when i attached the room class C# script to the main camera). I didn't attach this script to anything else.