I was just curious which method was best practice. I know they both have their uses but if you have a choice, which should you use?
I would use the “drag-and-drop” approach because using GameObject.Find, or any type of Find, especially repeatedly, will incur a performance loss.
another alternate way, which I find useful, is to do a Find in Awake only if the variable isn;t already set.
Awake() {
if (myScript == null) myScript = GetComponent(); //or Find() as appropriate
}
thanks that is what I thought (since there isn’t any search), but I wanted to confirm.
The awake way is cool too, since if only runs once.