No MonoBehaviour scripts in this file?? {Answered}

In unity 5 i tried making a script but when I do it shows what i included in the pic.

2 Likes

bump i still have not figured this out

What’s the exact file name? If it is anything else then NewBehaviourScript.cs, it won’t work. Upper and lower cases have to be identical as well.

1 Like

that is the exact file name, it is the default file name when I make a C# Script

Are there any compile errors?

Nope also i tried making another script and it is there when i first make it but if i click it again it is gone…

edit: when i click on the new script this came up as another script :

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2008

Project("{16FBE60A-881B-252E-4171-415BB07D355C}") = "Game Name", "Assembly-CSharp.csproj", "{132D20DC-77BA-457C-3BBD-F4AA182776AC}"
EndProject
Global
    GlobalSection(SolutionConfigurationPlatforms) = preSolution
        Debug|Any CPU = Debug|Any CPU
        Release|Any CPU = Release|Any CPU
    EndGlobalSection
    GlobalSection(ProjectConfigurationPlatforms) = postSolution
        {132D20DC-77BA-457C-3BBD-F4AA182776AC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
        {132D20DC-77BA-457C-3BBD-F4AA182776AC}.Debug|Any CPU.Build.0 = Debug|Any CPU
        {132D20DC-77BA-457C-3BBD-F4AA182776AC}.Release|Any CPU.ActiveCfg = Release|Any CPU
        {132D20DC-77BA-457C-3BBD-F4AA182776AC}.Release|Any CPU.Build.0 = Release|Any CPU
    EndGlobalSection
    GlobalSection(SolutionProperties) = preSolution
        HideSolutionNode = FALSE
    EndGlobalSection
    GlobalSection(MonoDevelopProperties) = preSolution
        StartupItem = Assembly-CSharp.csproj
        Policies = $0
        $0.TextStylePolicy = $1
        $1.inheritsSet = null
        $1.scope = text/x-csharp
        $0.CSharpFormattingPolicy = $2
        $2.inheritsSet = Mono
        $2.inheritsScope = text/x-csharp
        $2.scope = text/x-csharp
        $0.TextStylePolicy = $3
        $3.FileWidth = 120
        $3.TabWidth = 4
        $3.IndentWidth = 4
        $3.EolMarker = Unix
        $3.inheritsSet = Mono
        $3.inheritsScope = text/plain
        $3.scope = text/plain
    EndGlobalSection
EndGlobal

bump

If you create an empty project, can you create a new script in there without that issue? Is it possible to create the script and then directly add it to a game object?

Yes it seems to only be on 1 project i might have changed some setting mistakenly.

This happened to me when I first started using Unity last week. It turned out a script I was working on but deleted was still being picked up by unity. I went into my documents and deleted the script from there and the error went away. Im new to programming so I don’t know much at all but that’s what worked for me with so its worth a shot brother

2 Likes

I think that may be what i did as well when i deleted it, the error is now gone thanks for the help guys!

When I deleted the script in my document it got rid of it in my game to.

yes it will do that the folders are connected (eg. if you make a folder in your games folder it will appear in unity as well)

I figured it out it was my McAfee real time scanning messing it up; I just deactivated it and the problem was fixed.

I just had the same problem. My solution? Copy and file’s content. Delete the file. Re-create the file and paste the content into the re-created file. The error went away.

3 Likes

I know i’m late but i just got unity tonight and i cant fix the problem with any of the above solutions.

Welcome to the forums!

You most likely have a compilation error in your script. The easiest way to get help is by posting the script here. Don’t forget to use code tags:
http://forum.unity3d.com/threads/using-code-tags-properly.143875/

Welcome to Unity!

Do you have any errors other that that it says there are no monobehaviour scripts with the file?

I have this error even for new (almost empty) scripts:


What “file” this message is refering to? What are “their names”?
How to fix this?

I’m using Unity 5.2.2f1 Personal
There’s link to my project:
https://dl.dropboxusercontent.com/u/17601731/forum/unity/FlappyBird.zip

has this happened with any of your other scripts or just this one?