How does FindObjectsOfType<> work?
i get an error that has to deal with FindObjectsofType<>
Assets/Script/HurtPlayer.cs(9,17): error CS0029: Cannot implicitly convert type LevelManager[]' to
LevelManager'
it is the same for my PlayerController. What do I do
Answer by Jessespike · Jul 26, 2016 at 08:54 PM
There are two similar methods. One returns a single object and the other returns an array of objects.
FindObjectOfType
FindObjectsOfType
Note the 's' in the word Objects.
LevelManager lm = FindObjectOfType<LevelManager>();
if you wanted to find multiple of objects of the same type:
LevelManager[] lm = FindObjectsOfType<LevelManager>();
Your answer
Follow this Question
Related Questions
Help with finding object and transform values 0 Answers
How can I gather a list of GameObjects from List of Types 0 Answers
Donkey Kong keg eject 0 Answers
Can you call script from another script ? 2 Answers
I have prefabs that should be referencing different GameObjects, but they all refer to the same one. 0 Answers