What is the difference between using
GameObject.Destroy() in Unity?
So, could someone explain the matter foolproof, please?
GameObject.Destroy() is inherited from
Object.Destroy(). Both statements refer to the same method.
This is not explicitly clear in the official API documentation, but most programmers can assume that to be the case based on the fact that both
Object contain the method, and
GameObject inherits from
Object. It can then be confirmed through IDEs or through the unofficial decompied source-code by MattRix on GitHub (
GameObject's source code does not contain the
Destroy() method, meaning it can only come from inheritance).
As such, you will also find the
Destroy() method on anything else in the inheritance tree of
Object. For example,
Component also inherits from
Object, and so you can add a
Destroy() statement within any component's code, without explicitly including
Object. before it.
Note: My answer is independent, but some credits to Hellium for answering correctly first in the OP.