Version: 2017.3

Compass.magneticHeading

切换到手册
public float magneticHeading ;

描述

相对于磁北极的航向(单位为度)。(只读)

始终在当前方向上相对于 屏幕顶部测量此属性中的值。 磁北极的航向 与真正的地理北不完全相同 - 要获得 准确航向,请使用 trueHeading 属性。

    function Update () {
        // Orient an object to point to magnetic north.
        transform.rotation = Quaternion.Euler(0, -Input.compass.magneticHeading, 0);
    }