Search Unity

Unity How to detect sprite mssing? or null?

Discussion in 'Scripting' started by tim12332000, Sep 23, 2019.

  1. tim12332000

    tim12332000

    Joined:
    Jun 15, 2017
    Posts:
    20
    I want to detect image sprite is "Missing" or "None"

    When I Get this sprite , They all got "null" like this , So How do I know it is "Missing" or "None" ?

    PS : I want to know it is missing or none , it is different situations for me.
     
  2. WarmedxMints

    WarmedxMints

    Joined:
    Feb 6, 2017
    Posts:
    1,035
    You could use Object.ReferenceEquals(sprite, null) as a missing sprite will should return false due to still having an instanceId and it should return true if it is null. Of course, it will return true is there is something populating the field as well.