Is there a way to check from within a function if an argument is a static variable?
This would help me prevent any possibility of typos where the user tries to quickly setup a singleton, but forgets to declare his own instance
member as static
before supplyng it to us via ref
here is my function:
// returns 'false' if failed, and the object will be destroyed.
// Make sure to return from your own init-function if 'false'.
public static bool TrySet_SingletonInstance<T>(this T c, ref T instance) where T : Component {
//if(instance is not static){ return false } //<--hoping for something like this
if(instance != null){
/* cleanup then return */
return false;
}
instance = c;
return true;
}