public Vector3 localPosition ;

描述

相对于父变换的变换位置。

如果变换没有父级,则其与 Transform.position 相同。

    // Move the object to the same position as the parent:
    transform.localPosition = Vector3(0, 0, 0);

// Get the y component of the position relative to the parent // and print it to the Console print(transform.localPosition.y);

注意,在计算世界位置时,父变换的世界旋转和缩放将应用于本地位置。 也就是说,虽然 Transform.position 中的 1 个单位始终为 1 个单位,但 Transform.localPosition 中的 1 个单位将按所有祖先的缩放进行缩放。

Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961