Know when screen orientation has changed on mobile? better to keep one orientation?

How can I know when a user has changed the screen orientation in a game? and is it better to lock it to one orientation anyway?

Based on your game, you may want to lock it. Some games allows to rotate, then the UI needs to be done so that it does not go weird.

Simple way to check for rotation:

public class OrientationSystem:MonoBehaviour{
    public Action<DeviceOrientation> OnOrientationChange = ()=>{};
    private DeviceOrientation  previous = DeviceOrientation.Unknown;
    private void Start(){
          previous = Input.deviceOrientation;
    }
    private void Update(){
          if(previous != Input.deviceOrientation){
               previous =  Input.deviceOrientation;
               OnOrientationChange( Input.deviceOrientation);
          }
    }
    private void OnDestroy(){ OnOrientationChange = null; }
}

Other way is to create a bridge between the native side and Unity.

My guess is you are having the mobile trouble where proportions change with the auto rotate. I just went to the build menu, player settings, and selected on rotation view. I think this is what you want to do, but, if not, I might be able to get back to you. Bye!