I had a cube that had a script on it. The script cube.js accessed another script main.js. I set up a variable in cube.js
var mainScript : Main;
that allowed me to drag my Main script onto the cube.js script in the inspector. Then I had to make the cube a prefab and when I did that I couldn’t drag the Main script onto the cube.js script.
Is there a work around for this? Or is there a way to just code : mainScript = main.js?
Thanks
I think I know what KieranG is trying to do. Basically AFA I understood, he is trying to drop a script in editor which is linked to a gameobject which is not a prefab, on a public script declared in a prefab script.
If this is correct, then what you are doing is not possible by just drag and drop. The reason behind this is that a prefab exists on project level and any other gameobject that is created in the editor or in script (and is not a prefab) exists on scene level. You can not assign anything scene level to anything global as that will cause it to break on scene change.
The work around I use in this case is I make both of them as prefabs. I am not sure that is efficient, but it works. After that you can drop the scripts between these prefabs.