Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

The object of type 'Image' has been destroyed but you are still trying to access it. Your script sho

Discussion in 'UGUI & TextMesh Pro' started by nventimiglia, Oct 30, 2014.

  1. nventimiglia

    nventimiglia

    Joined:
    Sep 20, 2011
    Posts:
    153
    So I have a pretty nasty exception that pops up at random times in my game. Not sure the cause as the stack trace is limmited to methods inside of Unity. The exception is followed by a lockup of the UI (mouse / touch stop working) as the exception spams itself.

    I have submitted a rather large bug report (as I was unable to replicate the error in a reduced project). I was wondering if anyone else has run into this issue or something similar.

    Case 644085

     
    gregory_igromatic likes this.
  2. JeremyDB

    JeremyDB

    Joined:
    May 29, 2014
    Posts:
    12
    I just updated to 4.6b21 and am now seeing this error, which seems to spam every update from the EventSystem. Going to revert back to 4.6b20 since it is blocking, but it would be nice to get more information on why it occurs.

    It also blocks all input events in my game, as the OP mentioned
     
    nventimiglia likes this.
  3. nventimiglia

    nventimiglia

    Joined:
    Sep 20, 2011
    Posts:
    153
    I reverted back to b20. It did not help. Whatever was updated when I went to b21 persisted when I downgraded.
     
  4. JeremyDB

    JeremyDB

    Joined:
    May 29, 2014
    Posts:
    12
    Huh .. my downgrade did seem to fix things. I did revert the QualitySettings file, which p4connect picked up as a changed file. It didn't appear to have any deltas when I glanced at it, though I might have missed something.

    Thanks for submitting the report. Unity guys (if you read this): let me know if you want anything from me in regard to the bug.
     
  5. Togis

    Togis

    Joined:
    Aug 24, 2014
    Posts:
    4
  6. Mikael-H

    Mikael-H

    Joined:
    Apr 26, 2013
    Posts:
    309
    Same issue here. In my case it is when I return to my starting scene efter playing in the main scene. Working in b20. If anyone needs details let me know
     
    gregory_igromatic likes this.
  7. gregory_igromatic

    gregory_igromatic

    Joined:
    Feb 1, 2014
    Posts:
    25
    Got this error in b21. It is fired after i destroy my old objects. I thought i had to remove some event listeners OnDestroy but failed to fix it till now.

    I've managed to deal with it using .SetActive and something like object pool
     
  8. Mikael-H

    Mikael-H

    Joined:
    Apr 26, 2013
    Posts:
    309
    Somehow I fixed my issue, I think it might have had something to do with UI components that were disabled during startup but I'm not sure and now I can't reproduce
     
    Filein likes this.
  9. gregory_igromatic

    gregory_igromatic

    Joined:
    Feb 1, 2014
    Posts:
    25
    Seems like fixed in 4.6 rc1. Returned some my code from gameobject.SetActive to Destroy and no errors.
     
    CanisLupus likes this.
  10. JeremyDB

    JeremyDB

    Joined:
    May 29, 2014
    Posts:
    12
    Yeah, works for me too
     
  11. CanisLupus

    CanisLupus

    Joined:
    Jul 29, 2013
    Posts:
    427
    Yep, updating to 4.6.0f1 (RC1) also solved it in my case.
     
  12. Filein

    Filein

    Joined:
    Oct 23, 2014
    Posts:
    7
    I had same issue in b21, but I fixed it. It seems like you call to GameObject.SetActive(false) in Awake(). Don't use SetActive(false) in Awake(). Maybe it works. :)
     
  13. smetzzz

    smetzzz

    Joined:
    Mar 24, 2014
    Posts:
    145
    Have you tested in the U5 beta? I'm getting these errors in U5 now.
     
  14. HoldShort-21

    HoldShort-21

    Joined:
    Sep 19, 2014
    Posts:
    1
    I was getting this error as well, but eventually figured out my problem:

    I am using delegates and events in the project. I was adding objects to listen for certain Events -
    void Start () {
    EventManager.OnEvent += SomeMethod;
    }

    But I failed to remove the objects from listening to Events -
    void OnDisable () {
    EventManager.OnEvent -= SomeMethod;
    }

    Noob mistake on my part, but it might be helpful to others.
     
  15. JeremyGalxyz

    JeremyGalxyz

    Joined:
    Nov 15, 2014
    Posts:
    4
    We're seeing this exception in 4.6.2f1. One way to trigger it is to tap away from Unity to lose focus, then tap on the game window again to regain focus, which spams the exception. We have no idea why.
     
  16. Michio-Magic

    Michio-Magic

    Joined:
    Dec 25, 2014
    Posts:
    18
    I think i found the problem, boys !!
    Something similar happened to me:

    "MissingReferenceException: The object of type __ has been destroyed but you are still trying to access it. Your script should either check if it is null or you should not destroy the object."

    i had this for an hour trying to get rid of it by disabling every script and game object. i finally realised it was because I had a second inspector window locked (upper right icon) so I could set some variables in the inspector. When I unlocked it, this error went away. (ps. this error CAN be reproduced ... and I am using unity 5.2.1)

    Hope this helps someone else to not lose their mind :)
     
    MikoDee and efreet like this.
  17. MikoDee

    MikoDee

    Joined:
    Dec 5, 2015
    Posts:
    1
    This totally fixed it! Thank you :D
     
  18. charmi212121

    charmi212121

    Joined:
    Feb 4, 2015
    Posts:
    4
    @HoldShort-21
    Yeah I made the same mistake and now got it working after 2 hours, all thanks to you!
     
  19. naumanarif

    naumanarif

    Joined:
    Jan 11, 2018
    Posts:
    1
    Work For Me Thank you so much!
     
  20. SoulsElite

    SoulsElite

    Joined:
    May 4, 2020
    Posts:
    1
    I searched and found my log in just to thank you.

    Also my noob mistake. Regards.
     
  21. xellso

    xellso

    Joined:
    Jul 31, 2018
    Posts:
    2
    I made an even more noob mistake similar to yours. I subscribed in OnEnable and unsubscribed in OnDestroy. After a scene switch the error occured automatically, because i subscribed more than one time to events (OnEnable got called on every UI screen pop up but unsubscribed only once when destroyed) ..

    Just in case someone else did the same error.