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
0
Question by MediaGiant · Jul 06, 2014 at 11:59 PM · undodifference

Determine difference between Undo and Redo operations

Hi all,

I'm using Undo.RecordObject to undo changes to a mesh and need to do a clean up after the user presses Ctrl-Z but can't determine the difference between this and Ctrl-Y.

The following code tells me that something happened but I can't find any extra info.

 if (Event.current.type == EventType.ValidateCommand)
 {
     switch (Event.current.commandName)
     {
         case "UndoRedoPerformed":
             Debug.Log ("What actually happened?");
         break;
     }
 }

Thanks in advance for any help.

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 MakeCodeNow · Jul 07, 2014 at 12:02 AM

Unity's Undo is designed to be automatic. As long as you properly record all of the creation/parenting/changes, then Unity will handle the Undo and the Redo for you automatically. Catching the UndoRedoPerformed event using the string command name is pretty far into undocumented/unsupported territory, and should really only be used if you need to do something like reset a UI on Undo or Redo. I'm not aware of any way to get the list of changes for that Undo or Redo.

Comment
Add comment · Show 2 · 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 MediaGiant · Jul 07, 2014 at 01:02 AM 0
Share

Thanks $$anonymous$$akeCodeNow, it does feel like I'm far into undocumented/unsupported territory here. Chris Herold suggested that there should be a separate UndoPerformed and RedoPerformed notification here back in early 2012 which would have saved me a lot of work.

Since I'm working with procedural modeling, and custom data, the only way to handle this that I can think of is to keep an array of vertices for each step of the creation process and compare these (point by point) to the current vertices to deter$$anonymous$$e if the user has stepped forward or backwards.

If the keystrokes weren't hidden from the custom editor when an Undo or Redo is performed then I could have just flagged the UndoRedoPerformed notification and checked for a Z or Y key press, but unfortunately this doesn't work. Thanks again for your take on this.

avatar image MakeCodeNow · Jul 09, 2014 at 03:51 AM 0
Share

No prob. Another idea would be for you to not register with Unity undo and just have your own Undo and Redo button. That way you could keep your own modifier stack and avoid really gross, exhaustive comparisons just to see what's changed.

PS -please mark answer as accepted :)

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Custom data for undo/redo action? 0 Answers

undo and redo 0 Answers

Repaint on Undo 5 Answers

Can my EditorWindow intercept Undo Redo Keyboard commands? 0 Answers

undo redo disabled 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