#Finding Component In Object

1 messages · Page 1 of 1 (latest)

glad kiln
#

Hey there, I was trying to find GameManager in the hierarchy. Ran some debug lines, seemed to find it just fine. Problems came up when I tried to find the script for it. It is also named GameManager, but I figured that wouldnt be a problem since it's specified to check components. I'm trying to figure out what's wrong, but can't seem to.

(one more detail, I did try inputting the component as both "GameObject" and "Game object", with the one with the space giving compiling errors).

#

also GameManager is in the hiearchy, its not something thats generated in a start() script

slim swan
#

consider using direct references instead of Find

#

perhaps a serialized reference, or even maybe a singleton in this specific isntance

fast peak
#

Yeah this 100% calls for the singleton pattern

#

The reason this code is failing could be something as simple as you having an extra space character at the end of the object's name for example

#

You also cut out the log line right before the error

#

which would tell us a lot

glad kiln
#

i see thank you guys, and as for the log error its just more of the same

glad kiln
fast peak
#

it's just not good practice to use for this kind of thing