- Home /
Reference Variables and Drag-And-Drop
Hello,
Recently I've been taking a liking to using Transform variables instead of using some GetComponent call on runtime.
However, now that my first project is starting to get some headway, I'm wondering if this is the best method. Probably not, but I want to know what exactly is happening right now.
For the sake of example, let's say we have a "VendingMachine" gameObject with a script component called something like 'dispense.cs,' which takes variables for one transform (some empty object called "DispensePoint") and another (a prefab of a ball called "Ball").
Whenever the project builds and runs, and "VendingMachine" gets created, does the engine store a reference to those transforms, to use the 'same' DispensePoint, or does it store an entirely new transform variable copying those objects? Does it matter if the source of the transform is within the same object as the component (i.e. the DispensePoint) or with an outside prefab not defined at all in any current gameObject (the Ball) or anything like that? (Sorry if this was asked before, but I'm at a loss for how I would search for this.)
Thanks.
Your answer
Follow this Question
Related Questions
Is calling GetComponent multiple times bad? 2 Answers
Distribute terrain in zones 3 Answers
Optimising references to other scripts 1 Answer
Help with Optimizing Voxel Code? 1 Answer
GPU Instancing performance variation 3 Answers