ProwlEngine / Prowl

An Open Source C# 3D Game Engine under MIT license, inspired by Unity and featuring a complete editor and built on Silk.NET
MIT License
360 stars 30 forks source link

[Editor] GameObjects lingering even after deletion? #75

Closed michaelsakharov closed 9 months ago

michaelsakharov commented 9 months ago

Not entirely sure what's happening here, but if you create a gameobject, and then delete it while it's selected, the Inspector continues to show it, and you can continue to edit it.

The Inspector uses a WeakReference, which means the garbage collector should be collecting the gameobject and the inspector should lose it. But something is holding onto the gameobject still.

https://gyazo.com/3915a998579d183ebd5ebf8cb55ca785

10xJosh commented 9 months ago

I was looking at this issue with WinDbg and it is getting deleted it just takes a couple of minutes for the garbage collector to collect it.

I added && engineObj.IsDestroyed == false to the conditional statement else if (customEditor.Value.Item1 == engineObj) on line 116 in the InspectorWindow.cs file for the inspector menu to disappear after clicking delete. Seems like the inspector menu will stay there as long as nothing else gets selected.

michaelsakharov commented 9 months ago

The editor camera is ok to stick around.

I originally had the isDestroyed check on inspector but after switching to WeakReference i was hoping to use IsAlive instead. If its a GC issue then isDestroyed will have todo.