How to delete an ISelectable via another button?

I have a class that has an ISelectHandler and IDeselectHandler. This is attached to a list item that upon selection by the user changes color. How do I both still use the DeselectHandler and allow the user to select the object and click a delete button?

For example, when the object is selected and the user goes to click the delete button, as soon as they click the delete button the IDeselectHandler runs and the object is deselected.

Just track it yourself. When you click on a selectable object, store it’s gameobject in a variable. Then when you click on delete, check if that variable has a value and run the destroy on that variable and then set the variable to null, or whatever works for your scenario.

2 Likes