• 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 kortemey · Jun 13, 2018 at 07:52 PM · objectbugserializationscriptableobject

Weird Custom Editor bug

Hello,

We are encountering a problem when attempting to use a [System.Serializable] ScriptableObject called NodeData. One of its public member variables is of type UnityEngine.Object. We use this type so we can drag a wide variety of different things into this field in the Inspector. This has been working great for dragging Prefabs, Images, AudioClips etc. into that field.

Our problems began when we started attempting to drag a different type of ScriptableObject (completely unrelated to NodeData) into the field. Though this initially worked fine (ScriptableObject descends from UnityEngine.Object), this has caused a bunch of strange issues later.

  1. Upon restarting Unity Editor and selecting the NodeData ScriptableObject we edited, that Object field looks like this:

There are weird parentheses for some reason. alt text 2. Upon entering play mode, this goes away and is replaced by how the field should look: alt text 3. Though the game works as expected in the Editor, on any built version, that field is interpreted as being null, even though it is definitely filled in the Editor.

Our hypothesis is that Unity is not properly serializing the Object field when we drag a ScriptableObject into it. We are using Unity 2017.3.1f1.

We can work around this issue by using a Prefab instead of a ScriptableObject, but this would require a bunch of refactoring. Does anyone have any ideas?

Thanks!

screenshot-12.png (23.7 kB)
screenshot-13.png (31.5 kB)
Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by kortemey · Jun 13, 2018 at 11:22 PM

Found the issue. This comes from having the ScriptableObject filename not the same as its name. I am not sure why this would cause this particular issue. Any insight would be appreciated.

Comment
Add comment · 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 Bunny83 · Jun 13, 2018 at 11:46 PM 1
Share

Well, an asset has an asset ID (basically a GUID). This GUID is stored in the ".meta" file next to the actual assetfile. So the file is actually linked to the specific assetID. Serialized asset references just store that asset id. A ScriptableObject (or $$anonymous$$onoBehaviour which is essentially the same on the native side) instance also has a link to the script asset where the class is defined. This is the assetID of the script file. Unity can't find the actual class when resolving the class name for the instance. $$anonymous$$onoBehaviours usually break totally when the file name doesn'T match the conntained class.

avatar image kortemey · Jun 13, 2018 at 11:49 PM 0
Share

That makes sense. Thank you very much!

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

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

101 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

Related Questions

Saving UnityEngine.Object into ScriptableObject 1 Answer

Scriptable Object List values are always null 1 Answer

How can I create, via script, a hidden subasset (ScriptableObject) that is editor-only and invisible in Project view? 1 Answer

I have a class derived from ScriptableObject, and members are getting serialized when I don't want them to be. 1 Answer

Save EditorWindow to disk 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges