How can you change the gravity variable depending on your Scene?

I’m working on a science fiction game but I need some help with one thing gravity. The game is set on multiple planets and needs to have the gravity variable change to be set accordingly. Could somebody send me a script of how to do that?

print(Physics.gravity) // prints the current gravity, default gravuity is Vector3(0, -9.8, 0) that means force on Y axis to down.

Physics.gravity = new Vector3(0, 9.8f, 0); // changes to new gravity, in this example, 9.8 on Y axis to up(reverse to default)

Just create a simple script like this:

// SetGravity.cs
using UnityEngine;

public class SetGravity : MonoBehaviour
{
    public Vector3 gravity = new Vector3(0, -9.8f, 0);
    void Start()
    {
        Physics.gravity = gravity;
    }
}

Just add this script to any object in each scene and set the gravity you want in the inspector. When the scene is loaded (and therefore the script on the object in the scene) it will automatically set the gravity to the desired value.