Unfortunately the documentation doesn't show you an example in C#, but it's pretty straight forward.
What you'd end up doing is something like
SpawnBehavior sb = gameObject.GetComponent<SpawnBehaviour>();
SpotClicked sc = gameObject.GetComponent<SpotClicked>();
//Do whatever you want with the variables from either MonoBehaviour
There is also the non-generic version
SpawnBehaviour sb = (SpawnBehaviour) gameObject.GetComponent(typeof(SpawnBehaviour));
but hey, if you can save some keystrokes and casts, why not.
Of course you could cache those components in your Start()
, if you're going to access them multiple times anyway. Calling GetComponent is expensive, particularly if you end up doing it every frame for example.
And if you subsequently want to set a boolean variable to true for SpawnBehaviour, you'd do
SpawnBehaviour sb = gameObject.GetComponent<SpawnBehaviour>();
sb.stoppedSpawn = true;
or if you don't care to keep the SpawnBehaviour around, you can do
gameObject.GetComponent<SpawnBehaviour>().stoppedSpawn = true;
But if you need it anywhere else, or need it often, do cache it.