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 mcmikecreations · Sep 02, 2017 at 10:53 PM · editorassetassetsscriptableobject

ScriptableObject Asset corrupted after reload of Unity

alt textHow it should look like.alt textHow it looks like after reload of Unity.

Here is the ScriptableObject:

 public abstract class ISplineMesh : ScriptableObject
     {
         public Vector3[] verts;
         public Vector3[] normals;
         public Vector2[] uvs;
         public float[] uvBounds = new float[4];
         public int[] tris;
         public float Vdist;
         public bool ok = false;
         public abstract string ID
         {
             get;
         }
         public string label;
     }

Here is how it is Saved:

 private void SaveAsset()
     {
         string label = splineMesh.splineMesh.label;
         AssetDatabase.DeleteAsset(Application.dataPath +
             "/Plugins/Nick's Ultima/UltimaRoadGen/Resources/RoadTypes/" + label + ".asset");
         if (label == null || label == "")
         {
             label = "Temp";
         }
         if (createNewAsset)
         {
             if (System.IO.File.Exists(Application.dataPath +
             "/Plugins/Nick's Ultima/UltimaRoadGen/Resources/RoadTypes/" + label + ".asset"))
             {
                 int count = 0;
                 while (System.IO.File.Exists(Application.dataPath +
             "/Plugins/Nick's Ultima/UltimaRoadGen/Resources/RoadTypes/" + label + "_" + count.ToString() + ".asset"))
                 {
                     count++;
                 }
                 label = label + "_" + count.ToString();
             }
         }
         Debug.Log("Saved asset as: "+label);
         if (!System.IO.File.Exists(Application.dataPath +
             "/Plugins/Nick's Ultima/UltimaRoadGen/Resources/RoadTypes/" + label + ".asset"))
         {
             AssetDatabase.CreateAsset(splineMesh.splineMesh,
                 "Assets/Plugins/Nick's Ultima/UltimaRoadGen/Resources/RoadTypes/" + label + ".asset");
         }
 
         splineMesh.splineMesh.label = label;
         AssetDatabase.SaveAssets();
     }

The interesting thing is that the file on the disk still exists and takes up 4kb of space! Edit: Saved Assets also don't work with Editor.ObjectField!

безымянныи.png (10.7 kB)
безымянныи.png (5.1 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

Answer by Bunny83 · Sep 03, 2017 at 11:59 AM

Uhm your class is an abstract class. Abstract classes can't be instantiated. Well, Unity's serializer partly managed to "forcefully" create an instance in memory, but it's generally not possible and not the intention of an abstract class.

Your code does not show if you actually may use a non abstract subclass. However since the MonoScript field is None you most likely used the abstract class

Comment
Add comment · Show 1 · 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 mcmikecreations · Sep 03, 2017 at 12:07 PM 0
Share

The actual class being saved is this one, it just contains a lot of code so I didn't want to include it.alt text

безымянныи.png (32.6 kB)

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

89 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

Related Questions

Are all ScriptableObject assets included in the build? 4 Answers

Problem with ScriptableObject and Custom Editor 2 Answers

Is there a message to be listen to when editor enter play mode? 2 Answers

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

Auto-refresh assets after changing scriptable object 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