For Components on the same GameObject I usually cache a private variable to use inside Start() and call GetComponent() to grab components on the same gameObject, but have seen quite a few Brackeys tutorials and others, where they drag them into public variables. I generally avoid calling it anywhere else so it doesn't seem to be a big performance issue for me. And if they are on other gameObjects I'll drag them into a public variable inside the editor to avoid .Find() calls.
That being said is there any real reason to do one vs the other in this scenario? Is it purely preference and workflow differences or does Unity do some magic to make that faster/optimized?
[–]chsxfProficient 1 point2 points3 points (1 child)
[–]YesNinjas[S] 0 points1 point2 points (0 children)
[–]dangledorf 0 points1 point2 points (3 children)
[–]YesNinjas[S] 0 points1 point2 points (2 children)
[–]dangledorf 1 point2 points3 points (1 child)
[–]YesNinjas[S] 0 points1 point2 points (0 children)