Skip to content
This repository was archived by the owner on Feb 11, 2024. It is now read-only.

2DSE: Added Undo and Redo support.#201

Open
Henry00IS wants to merge 10 commits intosabresaurus:masterfrom
Henry00IS:2dUndoRedo
Open

2DSE: Added Undo and Redo support.#201
Henry00IS wants to merge 10 commits intosabresaurus:masterfrom
Henry00IS:2dUndoRedo

Conversation

@Henry00IS
Copy link
Collaborator

@Henry00IS Henry00IS commented Dec 25, 2018

Thanks to @vertxxyz's tips I was able to easily add undo and redo support to the 2D Shape Editor.

This has since evolved in #198.

Does not allow undo/redo of extruded brushes, this is purely for the editor window itself.

…ir own undo/redo history while they have keyboard focus.

The 2D Shape Editor now uses this helper class and implements a custom history system.
Currently the latest project state can no longer be accessed with redo, this has to be fixed yet.
…StackHelper` to `UndoRedoBarrier` which is a more accurate description of what it attempts to achieve.

C# type `Stack` does not get serialized and can't survive C# recompiles (the history is lost).
…zed by Unity. This causes the undo/redo history in the 2D Shape Editor to be lost after C# recompilations which is detrimental to the user experience.

Created two extension methods; `List<T>.Push<T>(value)` and `List<T>.Pop<T>()` respectively that simulate identical behaviour to `Stack<T>` on `List<T>`.
…s returning null on ScriptableObject.CreateInstance.
… 2D Shape Editor window is already open when Unity Editor starts (Init method is never called).
…ept and cancel CTRL+Z and CTRL+Y.

Unity editor 2017 (tested with 2017.4.17f1) uses the fake undo history and exploits behaviour only found in 2017 that allows redos without there being a redo.
Unity editor 5 users will have to be happy with undo functionality alone.
… selected objects list will be cleared to prevent null reference exceptions.
@Henry00IS
Copy link
Collaborator Author

Can someone on a mac computer give this PR a go?

Move some things around in your scene, press Command+Z and Command+Y in the 2D Shape Editor window to undo and redo things. It shouldn't affect the scene. Feedback on 2017 and 2018 are more than welcome.

You can download the ZIP file here.

@jmickle66666666
Copy link
Contributor

CMD-Z performs and undo in the scene, not in the 2D Shape Editor. Unity 2018.3 on Mac

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants