Search Unity

  1. Unity 2020 LTS & Unity 2021.1 have been released.
    Dismiss Notice

deletedGameObject.Equals(deletedGameObject) evaluates to false now.

Discussion in '5.5 Beta' started by Joebobaggins, Oct 27, 2016.

  1. Joebobaggins

    Joebobaggins

    Joined:
    Apr 26, 2016
    Posts:
    3
    deletedGameObject.Equals(deletedGameObject) evaluates to false now.
    (deletedGameObject == deletedGameObject ) still evaluates to true.
    so...
    (deletedGameObject == deletedGameObject ) != deletedGameObject .Equals(deletedGameObject)

    Object.Equals has been changed and no longer reacts the same as the overloaded Object == operator.

    Is this desired behaviour? That a deleted Object when compared against itself with == returns true. But when compared with Object.Equals it returns false.

    This shows itself when trying to remove "null" gameObject references from a dictionary. The remove will fail to find the reference to be removed.

    My work around is to define my own Comparer that uses exclusively ==, but the underlying change will probably hit a bunch of people.
     
unityunity