I have been following the excellent SpaceShooter tutorial and came across what seems to be a bug. When you create a script directly in the scripts folder (namely DestroybyTime) and try and attach it to a prefab object using “Add component - scripts” it isn’t listed but it is in the scripts folder. Upon further investigation none of the scripts I have created show in this list - only the presupplied scripts that I downloaded from the asset store. Is this a bug or just me - all the scripts show up if you search for “all scripts” in the explorer. Thanks
@ASH247 compare your script to the done_DestroyByTime script in the done folder under scripts.
I was having the same problem until I realized I had forgotten to change
public class NewBehaviourScript : MonoBehaviour
to
public class DestroyByTime : MonoBehaviour
Hope that helps!
Fen
Another thing that can cause this problem: a typo in your file name such that the name of the file does not match the class’ type.
I know this is old, but is the first link Google shows when searching for this specific problem.
I had the same problem when following another tutorial, and the solution is quite simple once you know the mistake you were having… when following a tutorial on scripting it seems that the authors are forgetting one step, after you write the script, you have to go to the menu and press “build all” (F8 as a shotcut)
After that step, the script should definetly show on the components
I hope this answer helps another newbie like me in the future
Thanks man, i was about to smash my head on the wall for not finding the problem… I was doing another tutorial but same problem it was the “NewBehaviourScript : MonoBehaviour” to the proper name.
A bit late on this one, but I stumbled across this thread whilst doing some searching on my own!
My solution was that i was trying to access another script which relied on other references/libraries.
I resolved this by just adding the ones the other one was using by entering “using unityEngine.(librarygoeshere);”
Hope my answer did any help to others scowering the same threads as i did!
Check if you have [AddComponentMenu] attribute. It could be a duplicate entry (Copy/Paste from another behaviour).
If this attribute is present this will be searched in Add Component.