I wanted to take a minute to announce that our latest Unity package has been released into the asset store!
It is a series of scripts that can be used to implement Undo/Redo support into your games or internal editor tools! It costs $10, and requires some C# scripting knowledge to create custom commands.
Asset Store Link: Here
More Info and Web Demo: Here
Let me know if you have any questions at all!
NOTE: The license in the asset store and on our website is only for game or internal tool use. If you want to use these scripts for any tools or middleware that you want to sell in the asset store or elsewhere, please contact us for a full use license.
This is outlined in the documentation that is provided with the package. In short, you need to create your own custom C# class deriving from an abstract class provided in the package. In the constructor, you need to pass in all of the data needed to perform the command. In the execute function you need to actually perform whatever the command does. And then you need to implement a function to create a command that is the opposite of what that command did. For example, if you have a command to hide an object, then you need a command to show an object. (This example is actually provided as a custom command in the package) There are a few examples provided in the package of how to create and use custom commands.
Well, I can’t buy the package to see the documentation , right?
To implement undo,redo, what you are doing is actually a stack. What is challenging is also to have objects that are deleted, but the commands still exist on the undo stack etc. Do you handle that, and have you hooked into unity api so it will be automatic, or I have to call your command to register the action.
I wasn’t implying that you need to buy it just to read the documentation, just that there is more detailed info in it as to how to use the package. I wanted to mention that before I gave you a quick overview of how to use it.
I do indeed use stacks to manage commands. What you are mentioning is definitely something that can be done, but as you point out, it is a more advanced type of command. You would need to keep track of all of the information used to recreate the deleted object. Such as prefab and serialized state. This is why I mentioned that advanced usage requires scripting knowledge in the product page.
Time Machine does not use the Unity undo/redo API, as it is editor only, and I wanted to be able to implement undo/redo for game systems as well. Beyond that, it lets you directly manage exactly what data is stored off, and how the undo/redo commands are processed.
You don’t need to register commands, just use them through the command history class. The only thing that is required is that they derive from a specified interface (which the provided abstract base class derives from as well)
Let me know if you have any other questions at all.
I have a question and based on this question I will buy the asset, currently I’m making a level editor for players and I want to implement undo/redo feature. Players will be creating and deleting objects, dragging objects with the mouse. so:
1- will your system be able to keep track of all created and deleted objects?
2-Will it be keeping track of changed parameters in scripts?