Unfortunately, now I am getting a warning within Unity itself:
You are trying to create a MonoBehaviour using the ‘new’ keyword. This is not allowed. MonoBehaviours can only be added using AddComponent(). Alternatively, your script can inherit from ScriptableObject or no base class at all.
Oddly enough, the code still appears to be working.
One follow up question though. Say I want to create want to insure Method1 is called from the same instance of ClassA using different instances of ClassB, is there a way to do that?
Just because the compiler accepts doesn’t mean it is correct. NullReference means you didn’t instantiate your object. GetComponent works by getting a script or other component that is attached to a game object in the hierarchy by selecting “Add Component” on your game object in the U.I. scene mode inspector, adding ClassA script to the object.
Try just ClassA _clsA = GetComponent(); after you add component.