Basic question about Unity functionality
Hi guys, I'm very new to coding and using unity.
Been following some tutorials to help myself learn, but have been running into issues with most of the tutorials being done in unity 4 (which through google I've been able to find the answers appropriately).
However, I just can't seem to understand what I'm doing wrong in this case.
I'll boil the very problem down to the basics.
1) I create a plane
2) I write a very basic script that interacts with the plane when I hover my mouse over it. Since it's for the tutorial, I also have a camera component on the script (as a public variable assignable in the inspector). The basic aspect of the script is a ray cast from the camera to my mouse pointer.
3) I apply the script to the plane.
4) I make the plane a prefab
5) I delete the original plane and re-add it to the hierarchy (not sure if necessary, just a habit I started doing)
6) I add the camera to the intended area attached to the script in the inspector.
Now, I test the functionality right here. Things are working properly, the script works.
So now I..
7) Duplicate the plane and align a few of them side by side.
These duplicates do not have the camera that was assigned to the script attached.
I cannot add the camera to the prefab itself
If I press the 'apply' button on the plane in the hierarchy, nothing changes for the prefab or for the rest of the planes
I can manually add the camera to all of the duplicates (and the script works for all of them while it runs)
ALSO OF NOTE: All other components follow over properly (e.g. the material color and transform position)
So I guess in the end my question comes down to how can I do this task in a more efficient manner?
If more information is necessary, I can provide it, but I believe I brought everything required.
Use GameObject.Find to look for the $$anonymous$$ain camera, or whatever camera it is you need in your script. This way the script will find its own reference.