acoppes / unity-history-window

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

Recover history from previously closed scenes #24

Closed acoppes closed 3 years ago

acoppes commented 3 years ago

Right now when moving between scenes, local selected objects are destroyed and the window automatically removes them or show them as deleted.

There is a way to recover the references by using https://docs.unity3d.com/ScriptReference/GlobalObjectId.html, I did some tests by converting from object to id, move between scenes and then go back and convert from id to object, and it recovers the references.

The idea in mind is try to store the global ids instead the Object pointer itself. Then, when moving to other scenes, the get object from id will fail and we can "hide" those "deleted" objects but avoid removing them from the history list so if we come back to the original scene they will appear again.

acoppes commented 3 years ago

I suppose it could be better to detect scene changes and store/load those global object id since it seems it might be slow to convert, and at the same time, we still want to detect deleted objects in the scene or assets, so this logic should consider those factors too (scene didn't change and the object is a scene object or not)