Destroy() not accessible from a static function?

I am writing a class library for use with unity and for some reasons Destroy() function is not available. How am I supposed to run it then? My function creates a temporary gameobject, but without destroy it cannot kill it after the operation is done, thus if the function is run again, it will create more and more of objects, filling up memory. Not good.

Try Object.Destroy(yourObject)

Since it is a method (not a static method) of GameObject, you probably need to specify an object. Instead of

Destroy(gameObj);

Try:

gameObj.Destroy(gameObj);  // inside static function, need a gameObject

It looks redundant, but I believe it will work. I don’t think it matters which gameobject you use for the beginning of the line; you could use your camera, or game controller object.