#GetComponent null, why?
1 messages · Page 1 of 1 (latest)
TextMeshProUGUI i think or whatever the name is for it
Isn’t it textmeshprogui or something else long like that
Ah yeah you're probably right. Just noticed TextMeshPro seems to be for 3d objects while UI might have its own
if you have the ref to playerPanel, you can directly ref the other ones too.
how?
how have you referenced _playerPanel ?
I store a ref at start with _playerPanel = GameObject.Find( "PlayerPanel" );
Thought storing a ref was more efficient 😳
[SerializeField] private GameObject playerPanel;
[SerializeField] private TextMeshProUGUI name;
🤔 I don't understand anything
I'm 1 month into unity so might need a link explaining what's going on
The gif is old but the process is the same
Putting what Don posted earlier, you can create a slot in the inspector that you can drag into
Then you don’t have to use .Find
Oh right, thought that was only for Public variables
serialize field exposes it to the inspector, but is private to this class
Oh that's awesome. thanks!
9/10 things you write as public... shouldnt be public
basically. if you have any type of Find in your code, you're doing it wrong
I don’t believe there’s a performance cost but idk
Yeah me neither since I store refs and don't call find every frame
but cleaner to just have them init at compiletime i guess
what happens if you change the name of the object?
your code is now broken
its unscalable
No
or maybe not if the script is from the prefab I suppose
Also no
The only time I ever use find/FindObjectOfType is when using DDOL since it breaks it from the hierarchy meaning I can’t drag reference it
I wonder if there’s a better way but idk
hmm, not showing up in editor?
Then you have errors
haha very true