• 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
Question by DaiMangouDev · Jul 11, 2015 at 01:29 AM · c#assetscriptableobjectdatabase

why are "The associated scripts can not be loaded" errors seemingly being thrown at random for .asset files

HI , This error seems to occur at random . Once I create the asset ,everything is fine . Sometime when there is a assembly reload I get this error and sometime I don't get the error , heck sometimes i get the error then it goes away ... same thing whenever i close and restart Unity.

Here is my code for creating this asset where Comp is the Class which inherits from ScriptableObject

  var asset = ScriptableObject.CreateInstance<Comp>();
 AssetDatabase.CreateAsset(asset,"Assets/NewFolder/Comp.asset");
                                                           
                     AssetDatabase.SaveAssets();
                     AssetDatabase.Refresh();

alt text

comp5.jpg (16.1 kB)
Comment

People who like this

0 Show 2
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 barbe63 · Jul 11, 2015 at 09:35 AM 2
Share

Check if the script name is the same as the Class that inherit from MonoBehaviour. Reassign it to the inspector.

avatar image DaiMangouDev · Jul 11, 2015 at 12:37 PM 0
Share

The Comp class was part of another script. I created a Comp.cs script and place the comp class in there.

It seems that not having the class name be the same as the script name will cause this problem.

1 Reply

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by DaiMangouDev · Jul 11, 2015 at 12:38 PM

The Comp class was part of another script. I created a new Comp.cs script and place the Comp class in it.

It seems that not having the class name be the same as the script name will cause this problem.

Comment
Deadcow_
yurypn
rockbyte
theLittleSettler
DylanYasen
PridesFall08
kirbygc00

People who like this

7 Show 2 · 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 Deadcow_ · Sep 01, 2015 at 11:37 AM 0
Share

Thanks a lot

avatar image theLittleSettler · Dec 27, 2017 at 08:51 AM 0
Share

still true in unity 5.6; It was happening for me predictably, every time I restarted unity

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

24 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Custom assets give Missing (Mono Script) 0 Answers

Weapon Database wtih scriptable objects 1 Answer

How to persist design-time data (excluded from the final game)? 1 Answer

How do I access assets of an asset database .asset file via c# ? 1 Answer

Saving UnityEngine.Object into ScriptableObject 1 Answer


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