Perhaps I’m getting ahead of myself here, but I’m a little confused by the behavior of using GetComponent<>
and FindObjectOfType<>
.
In this lesson, for example, we call FindObjectOfType<StarDisplay>().AddStars()
, but what if our Scene
contains more than on StarDisplay
object? How does Unity know which one we want?
This is even more confusing to me when using GetComponent<>
. We could have multiple Text
components on a single Canvas
, for example. If we just call GetComponent<Text>
, which one is returned?
Again, this might be explained further in future lessons, but I’d like to understand how Unity works in these cases.