• 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 JRule4 · Oct 11, 2012 at 05:30 PM · animationeditor

Store and Restore an object's state

I'm working on a custom "Cinematic Editor" where I can take objects and apply actions to them based on the time of the cinematic. Like the animation editor, I have it so that play the cinematic forwards, backwards, and frozen at a given time. My actions will store the initial values of the target objects so that it can restore it if the time is set to back before the action took place. This works great for all of the actions I have defined except an action to play a Unity Animation. I haven't been able to find out how to look up the values that an AnimationClip is going to modify, so I can't store and restore the values themselves.

 AnimationUtility.StartAnimationMode()
 AnimationUtility.StopAnimationMode()

These functions would work, if it weren't for the fact that a cinematic can play multiple animations at any given time, and StopAnimationMode can't restore specific GameObjects only. What i'm looking for is something that can store GameObjects' states and restore them interdependently from each other in any order.

Currently, I'm just creating a prefab via PrefabUtility and reverting the object to the prefab at will, but that causes a hiccup during Prefab creation and is a rather inelegant solution.

Comment
Add comment · Show 1
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 whydoidoit · Oct 11, 2012 at 06:18 PM 0
Share

You can use Unity Serializer to store and reload a GameObject's settings. Examples of doing this are in OnlyInRange$$anonymous$$anager

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Muuskii · Oct 11, 2012 at 06:05 PM

This is just a guess off the top of my head, and might not even be the "best" solution. But my first impression is that you could take a hint from the way networking in unity works:

When OnSerialize is called, your script serializes all it's data into a stream.

When OnDeserialize is called, you retrieve that information from a stream that is passed to you and set your GameObject's state.

This way you're saving state every couple of frames (or every frame) and can return to whatever frame you need to in whatever order.

When it comes to actual code to give you; I have none at the moment. But I could find it.

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 DaveA · Oct 11, 2012 at 07:44 PM 0
Share

Please feel free to use 'answer' ins$$anonymous$$d of comment. Comment when asking for more information or really anything but answering. This is a valid answer. Even if it may not be correct or the best.... but either way, that's why I moved it to 'answer'.

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

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

12 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

Related Questions

Can I set Animator State Transition defaults? 3 Answers

Is there a project setting that could be breaking animations? 0 Answers

How to make Bones visible in Editor Mode ? 5 Answers

Editing Animations crashes Unity 1 Answer

EditorGUI.Curvefield presets 1 Answer


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