Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
3
Question by MattMcg.GameDev · Sep 24, 2014 at 09:00 AM · editor-scriptingserializationundo

Undo.RecordObject is too slow on large arrays, alternatives?

I'm updating a single value in a Serialized byte array that is 1,000,000+ long.

So far, everything has been fine handling it.

I am changing these values through some input in the scene window (it's a tile-painter) and using Unity.RecordObject so I can add Undo functionality (as stated in the guide for writing sell-able assets). This function says it records the Delta changes and I wrongly assumed that meant: the changed indexes and their value from an array, but I think it means it only looks at each property that changes. So obviously, every time I call this, it checks a massive array for changes and I assume it does a whole bunch of serializing/deserializing. This causes a 5m-1000ms delay when trying to use my application...

What are my alternatives? I have tried splitting the data out over multiple serialized scriptable object instances. This works and is fast, the only downside is, I now have 100+ scriptable objects just sat in my asset folder. This is now very ugly to use.

Is there a method I can use to store them as serialized objects, without needing multiple objects in my asset folder? E.g. someway to bury each object as an individual property in a prefab? I can't just write a monster class with 100 arrays on it, as the world size is variable.

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 GameVortex · Sep 24, 2014 at 09:17 AM

I don't know much about the efficiency of RecordObject on large arrays. But a way you can clean up the 100+ scriptable objects in your asset folder is to combine them.

Create a root .asset (ScriptableObject file) and when you create the other files add them to the root file using AssetDatabase and then hide them so they won't show up in the folder (you should also probably add a reference to each of them to a variable in the root asset). You can then access all the assets through your custom editor window by loading up the root file only.

Example:

 Root rootAsset;
 
 private void AddNewAsset(SubAsset newAsset)
 {
     AssetDatabase.AddObjectToAsset(newAsset, rootAsset);
     newAsset.hideFlags = HideFlags.HideInHierarchy;
 }
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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Why is play mode reverting my scriptableobject to a previous serialized state? 2 Answers

BeginChangeCheck & EndChangeCheck not working? 1 Answer

Custom inspector variable resets automatically 1 Answer

SerializedProperty and PropertyField NullReference 1 Answer

undo redo + custom serialization slow 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