acoppes / unity-history-window

A simple selection history window for Unity.
MIT License
293 stars 24 forks source link

[Feature Request] Save History for Particular Scene #19

Closed rvv27 closed 3 years ago

rvv27 commented 5 years ago

The plugin is really Time saver but for the people who works on multiple scenes the history and favorites get erased when a new scene is loaded.

Maybe you can add a Scriptable Object per scene to store the selection history and load them on editor start. Thank you

rvv27 commented 5 years ago

I got it working, But I am sure that it would be not 100% appropriate way. So kindly check and let us know your remarks.

How it works: We create a scriptable object in a specified folder for everyscene and save history in it. When scene is saved we overwrite the scriptable object with new history and when scene is loaded we read history from it. Following are the code modifications:

New files added: SaveSelectionHistory.cs : https://pastebin.com/x9cmpFsF

Existing files modified: SelectionHistoryWindow : https://pastebin.com/B0M835f7 (Two lines added and two functions added)

SelectionHistory.cs : Allowed History List and Favourites List property to use Setter { list=value } so it can be modified from selectionhistorywindow.cs class

! One strange thing happens is that the scriptable object gets updated everytime the history and favorites lists are updated. However I have coded it to update only on EditorScene Saved and Opend

acoppes commented 3 years ago

Sorry I'm just seeing this today.. can't believe I didn't see the feature request before (my github notifications are not working for some reason).

So the feature is something like keeping history/favorites per scene, so if you close it and open it again, you recover your saved stuff?

A possible test case: open scene, select one or more objects, pin of of them, open another scene, open first scene and you have your history and pinned objects.

I'm not sure about using scriptable objects and uploading them to your version control, even having merge conflicts or stuff like that, but probably, it seems it has to be something in the user editor prefs or in a personal folder (like user settings), right? Will think about it.

acoppes commented 3 years ago

If you want, you can make a PR and I will merge it, the only addition I would suggest is having a new setting to the project to turn on/off this feature and leave it off by default. This is to avoid people using the plugin to having to take care of new assets appearing in the project without knowing why.

acoppes commented 3 years ago

Now history stores/restores selected stuff from unloaded scenes, and there is a new issue to save to disk before closing the editor and restoring that. Will close this feature request.