random loss of component variable value

This thread is on hold while I’m doing some testing, my conclousions beneth seem to be incorrect, need to update everything

I’m working in 2 scenes, creating an object with an UI Image that I hooked up to a variable. Can use it without problem. Then when changing scene the variable works until i disable the image component, right after nothing happens but when i try to activate it via the variable I get a message that the component Im refering to is destroyed. I have 0 clue what is going on. pls help, just a theory, anthing im desperate. thnx

Good day.

You disable the image? How? Did you check in inspector is still there? Are ypu sure the error refears that image? Are you not destroying it? What and how are you disabling and reactivating it? Did you changed scenes.

Check and be sure at 100% with no doubt all that questions. Post the code lines that gives you the error.

Im thibking now… If you changed scenes, except for all ‘NoDestoyOnLoad’ objects, all other are destroyed. If you are trying to refear something from the last scene will give you that errro. You need to find that image again, and if is not active, ypu need to assign it via inspector.

Good luck! Bye!

:void start(){

:Image comp = GetComponent();}

:public void enable(bool enable){

:comp.enabled = enable;

:debug.Log(comp);}

when enable = false, it works

when enable = true, it does not work

I get the message:
missing refrence exeption: the object of type “Image” has been destroyed but you are still trying to acces it.

the function works as intended in the first scene but in other scenes I get this problem. If I go to another scene and then back to the first scene it works, but get the error. Also if I try to acces the component variable in an update loop in the same class, it works all the time. message.@tormentoarmagedoom