- Home /
User Scripts not showing in "Add component - scripts"
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
if that script is C# then it should must match name of file and class name, for JS file name is the bydefalut class name and inherteed from monobehaviour
Answer by FenrisWolf · May 08, 2015 at 12:11 PM
@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
you ever see that meme where somebody has the exact same problem as you, but the question was posted years ago and nobody posted an answer?
I'm glad that didn't happen this time. Thank you for your annoyingly easy, yet hard to find fix!
Answer by TimK_personal · Jun 26, 2015 at 07:05 PM
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.
Answer by Jedah · Dec 22, 2016 at 06:32 PM
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
Answer by thiagolrlopes · Aug 12, 2017 at 09:20 AM
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.
Answer by esverin · Aug 25, 2017 at 01:16 PM
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!
Your answer
![](https://koobas.hobune.stream/wayback/20220613162612im_/https://answers.unity.com/themes/thub/images/avi.jpg)