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
0
Question by FranTapTapTales · Oct 17, 2019 at 11:29 AM · editoreditor-scriptingassetassetsclass

Scriptable object meta info is hidden, where did it go?

Situation: we use two engines to create games, in both engines we have the same game, to generate and store information about the layout in BOTH games, we use the ScriptableObjects generated in Unity, they are easy to read. For doing that we have the following:

 [CreateAssetMenu(fileName = "Flow level", menuName = "Flow level")]
 public class FFLevel : ScriptableObject {
     public string Name;
     public int total_paths;
     public Int2dArray grid;
     public bool has_walls;
     public bool[] walls_right; 
     public bool[] walls_bottom;
 }

[System.Serializable]
public class Int2dArray {
    public int length;
    public int x, y;
    public int Width { get { return x; } }
    public int Height { get { return y; } }
    public int[] m;
}
This generates the .asset file with all the info we need:
 //Ignored the non important parts like internal Unity Ids and such
  m_EditorClassIdentifier: 
  Name: There are walls
  grid:
    length: 8
    x: 2
    y: 4
    m: 0000000000000000ffffffffffffffffffffffffffffffffffffffffffffffff
  has_walls: 1
  walls_right: 0100010001000000
  walls_bottom: 0000000000000000
  total_paths: 1

The problem: When I wanted to add a new custom structure ( Portals):

 [CreateAssetMenu(fileName = "Flow level", menuName = "Flow level")]
 public class FFLevel : ScriptableObject {
     public string Name;
     public int total_paths;
     public Int2dArray grid;
     public bool has_walls;
     public bool[] walls_right; 
     public bool[] walls_bottom;

     public bool has_portals;
     public Portals portals = new Portals();
 }
 [System.Serializable]
 public class Portals {

     public int Length;

     public int[] p1_y;
     public int[] p1_x;

     public int[] p2_y;
     public int[] p2_x;
  } 


After doing so, the .asset file became empty, the information regarding the data structures is gonne but all the other stuff (internal Unity Ids and that) it's still there, yet all the information inside Unity's engine is kept untill I hit Play, I can see all the info in the Inspector window:

 //Ignored the non important parts like internal Unity Ids and such
  m_EditorClassIdentifier: 
  Name: 
  total_paths: 0
  grid:
    length: 0
    x: 0
    y: 0
    m: 
  has_walls: 0
  walls_right: 
  walls_bottom: 
  has_portals: 0
  portals:
    Length: 0
    p1_y: 
    p1_x: 
    p2_y: 
    p2_x: 

Where has all the info gone? What can I do to fix this, if it is even possible?

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 FranTapTapTales · Nov 21, 2019 at 03:10 PM

Okay, so... don't know exactly why, but when adding a bunch of structures (even being serialized by default) Unity starts to break and not mark the ScriptableObject as dirty and thus, not saving the changes when Unity is closed. To fix this I simply added a button to mark the ScriptableObject as dirty:

if (GUILayout.Button("Save")) { 
    EditorUtility.SetDirty(target);
}

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

161 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 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

Importing .png via script 1 Answer

Why Are My Project Assets Constantly Re-Importing? 2 Answers

EditorUtiltiy.GetAssetPreview(Object asset) 0 Answers

How do I get an array of names of all the sprites in a project, with an editor script? 2 Answers

How to : Editor.OnPreviewGUI Implementation 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