unity2d cannot create if gravity level

Hi everyone I am working on a new game where one of the main features is gravity flipping but I cant find a way to call an if statement that checks the gravity level for example.

if(Physics2D.gravity.y == -9.8f){
   dosomething();
}

thank you in advance

Looks like you’ve got it to me. Make sure your physics2d gravity is actually set at that value if you want it to do anything.