Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
1
Question by Kathlar · Jul 26, 2018 at 11:04 PM · errorinspectorerror messageeventexception

Inspector Error

I have started using Odin today. I'm not sure if it is its fault, but I started creating Scriptable Objects in my new project. I did this:

 public abstract class Ability : ScriptableObject
     {
         public string aName = "Ability";
         public Sprite aSprite;
 
         public AudioClip aSound;
         public float baseCoolDown = 1f;
 
         public abstract void Initialize(GameObject obj);
         public abstract void TriggerAbility();
       }

Now, whenever I try to change aSprite, aSound or play the game I get these two errors:

 UnityException: set_type is not allowed to be called from a ScriptableObject constructor (or instance field initializer), call it in OnEnable instead. Called from ScriptableObject 'ObjectSelector'.
 See "Script Serialization" page in the Unity Manual for further details.
 UnityEngine.Event.KeyboardEvent (System.String key) (at C:/buildslave/unity/build/Modules/IMGUI/Event.cs:153)
 UnityEditor.ObjectSelector..cctor () (at C:/buildslave/unity/build/Editor/Mono/ObjectSelector.cs:78)
 Rethrow as TypeInitializationException: An exception was thrown by the type initializer for UnityEditor.ObjectSelector

 set_type is not allowed to be called from a ScriptableObject constructor (or instance field initializer), call it in OnEnable instead. Called from ScriptableObject 'ObjectSelector'.
 See "Script Serialization" page in the Unity Manual for further details.
 UnityEditor.ObjectSelector:.cctor()

Any ideas what my be the reason?

Comment
Add comment · 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 kalen_08 · Jul 27, 2018 at 04:22 AM 0
Share
 [SerializeField] string aName = "";

Ins$$anonymous$$d of using public maybe? Then have a public property for other scripts to access

avatar image hexagonius · Jul 27, 2018 at 08:43 PM 0
Share

the class is abstract, what's the code for the concrete class?

1 Reply

· Add your reply
  • Sort: 
avatar image
5

Answer by JS101 · Aug 02, 2018 at 01:20 PM

I had the same error that would even show on a newly created project (with no extra packages installed).

Edit->Preferences->GI Cache-> Clean Cache

Edit->Preferences->Cache Server-> Clean Cache

Fixed the problem for me. Hope it helps someone else cause it drove me crazy.

Comment
Add comment · Show 7 · 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 Richie_V · Sep 07, 2018 at 09:19 PM 0
Share

Had the same issue in Unity 2018.2 and this resolved it, thanks for the tip

avatar image DaimonEspada · Nov 14, 2019 at 07:20 PM 0
Share

now its Unity->Preferences->GI Cache

avatar image DaimonEspada · Nov 14, 2019 at 09:57 PM 0
Share

@JS101 it seemed to have worked however after opening the project later it returned and now the solution isn't fixing it.

avatar image JS101 DaimonEspada · Nov 14, 2019 at 10:37 PM 0
Share

in 2019.2.8f1 it still Edit->Preferences->GI Cache-> Clean Cache for me

Also be sure to try and clear the Cache server in Edit->Preferences->Cache Server-> Clean Cache

Did you save the project after you fixed it before closing Unity?

avatar image DaimonEspada · Nov 16, 2019 at 05:28 PM 0
Share

Within my cache server, I don't have a clear cache option.

avatar image DaimonEspada · Nov 16, 2019 at 05:38 PM 0
Share

I fix it but the issue returns. I had it fixed again, now after 10 builds or so, it's back. However, your solution was fixing the initial issue, which is why I upvoted this solution.

avatar image hexagonius DaimonEspada · Nov 17, 2019 at 06:33 AM 0
Share

Again, why is it abstract? Is there a concrete implementation you did not show?

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

126 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 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 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 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 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 avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Need help with error ive never seen before: "MethodAccessException: Requires team license" 2 Answers

How to make a field in inspector to pass events like "On Click()"? 1 Answer

HingeJoint2D Input connectedAnchor is { NaN, NaN }. in Editor 0 Answers

Data folder not found 6 Answers

Webcam mapping buffer error 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