Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
11 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by C4ptainZA · Aug 10, 2015 at 11:29 AM · renamereimport

No Monobehavior scripts in the file error after trying to rename a script.

I tried to rename a script file name rather than recreating it.

Now I have an issue where all of my scripts say in the editor "No MonoBehavior scripts in the file, or their names do not match the file name".

I suspect the Unity generated files and reference numbers (guid's) now don't match the .meta numbers for my .cs scripts.

Is there anyway to reimport all my scripts without recreating the entire project?

Or is another issue causing this? I'm quite sure there is nothing wrong with the scripts themselves as they were all working prior to me renaming the one script file.

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image C4ptainZA · Aug 10, 2015 at 11:46 AM 0
Share

Want to add. This is Unity 5 Personal 64bit on Windows 10 (Windows 8 compatibility mode).

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by tanoshimi · Aug 10, 2015 at 11:31 AM

Script filenames need to match the name of the class defined within them. So if you changed MyScript.cs to MyNewScript.cs, you also need to change public class MyScript : Monobehaviour to public class MyNewScript : Monobehaviour

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image C4ptainZA · Aug 10, 2015 at 11:45 AM 0
Share

Not the issue. I have deleted the script I tried rena$$anonymous$$g and I am sure I renamed it correctly. Now every script on my project now has the error and I cannot add them to game objects.

If I do drag and drop my scripts onto the game objects I get "The associated script cannot be loaded", or it asks me to fix any compile errors before scripts can be loaded. Except there are no compile errors on the console, and all these scripts were previously working.

avatar image
0

Answer by C4ptainZA · Aug 10, 2015 at 12:22 PM

I have solved this issue.

One of my scripts had a compiler error. Seems this can block the editor from recognizing new scripts but also the console posting the compiler error (possible bug).

I only realized when I deleted all my scripts and re-added them one by one to the project.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by unity_r_Q4A19IbyMMAQ · Nov 21, 2021 at 09:21 AM

This happened with me recently. I know this must have already been solved for you but I just thought I'd spread word that I fixed it by making a blank script with the same name as the old script, then deleting the blank script.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

How to rename a script file? 8 Answers

rename scripts 1 Answer

[Solved] Renaming game object clones instantiated 1 Answer

Reimport standard meshes in Unity? 1 Answer

Linking a file outside the Asset folder to update an asset on reimport 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges