The question is answered, right answer was accepted
Gameobject goes missing after second iteration of event
Hey guys, i have problem with my script. I've got time manager with event action, and campfire script with listen the action, this script have also gameobject and amount of this gameobject. everything goes fine when time passes first time, but on second time gameobject is null, but amount is still correct, do you have any suggestion where can be problem?
I've checked all logic in script in every thing looks correct, also checked with debbuger calls and nothing set object to null from code. I bet on garbage collector or something simillar...
i even tried catch setting field on private setter with variable as private, and nothing sets gameobject to null from code. Is there posibillity to tell unity to not set this variable to null?
Answer by sebkewmeszke_unity · Dec 30, 2021 at 02:54 PM
I found solution, not the best, but working, problem is with passing by reference, so i maded empty game object named "GarbageCollector" and when passing new value just give him a instance of gameobject.