Page 1 of 1

Difference between Destroy and Dispose?

Posted: March 25th, 2016, 11:07 am
by icarus_allsorts
Specifically when it comes to a GameObject, it seems that in most cases where you'd want to get rid of an object Destroy is the go to method, but there does also seem to be some important-ish looking code in DIspose that would seem odd if it was never run on the object being destroyed. I guess my main question would be does Dispose() perhaps get used somewhere along the line after Destroy() runs?

Posted: March 25th, 2016, 5:04 pm
by Chain_Reaction
Destroy seems to only be useful when you want to remove the object from the world/simulator but not actually kill it's data structure (such has destroying a Sim object during hibernation). Dispose is when you want it to die. Generally I do both when getting rid of things. It appears EA is a big fan of destroy which is why ET is needed to actually get rid of the data using dispose.

Posted: March 25th, 2016, 5:18 pm
by igazor
Without meaning to, and without even asking a non-coder to participate over here, you guys have just solved a weird mystery for me that I had been saving to present some day. I have a screenshot taken in Edit Town at the precise moment an NPC babysitter left the lot where he was working, was on his way who knows where (home, off the map I suppose), and Tagger was reporting his current action as "Destroy Myself."

Am pretty sure players weren't really supposed to ever see that, but at least now I know what it meant, and it wasn't nearly as sad as I thought! :)

Posted: March 25th, 2016, 5:31 pm
by Chain_Reaction
Yes, service Sims run that interaction when they are going into hibernation. You wouldn't ever normally see what interaction they are running because it's not possible to make them selectable.

Posted: March 25th, 2016, 5:47 pm
by icarus_allsorts
Ah, so for an object that has no business being around in the game anymore I should run both Destroy and Dispose then, presumably in that order?

Posted: March 27th, 2016, 4:20 pm
by Chain_Reaction
Sounds good :)

Posted: March 28th, 2016, 12:54 am
by icarus_allsorts
Thanks :)