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 Gogeric · Sep 25, 2015 at 07:55 AM · scripting probleminheritancescripting-underthehood

ScriptableObject Inheritance Serialization failure

Hi,

Here is the issue i'm facing :

 public class Shapes : ScriptableObject {
     GetShape(){}
 }

 [CreateAssetMenu(fileName = "Quad",menuName = "Shapes/Quad")]
 [System.Serializable]
 public class Quad : Shapes {}
 
 [CreateAssetMenu(fileName = "Star",menuName = "Shapes/Star")]
 [System.Serializable]
 public class Star : Shapes {}

This is all in the same file.

Creating the assets works fine, but when i restart the editor or leave play, they do not get reloaded properly, that is because the script file associated to the scriptableObject asset is not set.

In the Yaml you find : m_Script: {fileID: 0}

instead of normally : m_Script: {fileID: 11500000, guid: e9c59ec9df3a4c942919c13d32e8cd99, type: 3}

Which appears correctly if those classes are in separated files.

I have 5 or 6 different base shapes, some shapes instanciators etc... I do not want to put them in different files, it is bad for my code flow, as i have a better view and understanding of the class hierarchy by having them all defined in the same file.

To go further is there any project for Unity to actually dissociate the meta of the serialized classes and prefabs from their script file GUID? and instead associate it to a GUID of the class itself? (like the class inheritance hierarchy that you can find here : m_EditorClassIdentifier: Assembly-CSharp::Star)

Why is it that Unity still links the script file to anything editor related, that makes inheritance very cumbersome...

Edit : If i correct the YAML by hand then it works and reload properly but i cannot fix the YAML by hand for any number of instances... that is a hack, if someone knows a solution to actually edit the .asset file by code when the object is created and fix this issue that would be great.

Furthermore, i use the GUID of the script where i defined the "Shapes" class but for any other configuration the GUID would be different.

It is a great limitation that Unity relies on the File names and Files GUIDs for the logic.

And also, if the editor serialize to text option is not set then i find myself with a binary and cannot fix that issue.

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 Gogeric · Sep 25, 2015 at 01:29 PM 0
Share

Any suggestions?

avatar image ZammyIsOnFire1 Gogeric · Feb 22, 2016 at 04:27 PM 0
Share

If you have found out something about this that will be awesome!

0 Replies

· Add your reply
  • Sort: 

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

30 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

Related Questions

Get script with GetComponent, but as base class 1 Answer

Adding script during runtime 2 Answers

How can I load in data for a derived type class from a CSV? 0 Answers

inheritance - problem setting class variable from external call 0 Answers

How do I best access a child script through a parent script when using inheritance 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