【问题标题】:How to make a RectTransform follow another RectTransform that is located under a different parent?如何使 RectTransform 跟随位于不同父级下的另一个 RectTransform?
【发布时间】:2020-02-14 18:33:55
【问题描述】:

我正在尝试使具有默认锚设置的 RectTransform 遵循右下对齐非拉伸的 RectTransform。但是,它们之间总是存在偏移量。

我尝试过 GetWorldRect().center 并将其转换为 WorldPoint,但没有成功。使用变换。 position 仅在两个 UIElement 都使用默认值锚定时才有效。

任何人都可以帮助填写以下方法主体吗?

public static void FollowRectTransform(this RectTransform source, RectTransform target)
{
}

【问题讨论】:

    标签: c# unity3d game-engine


    【解决方案1】:

    您可以使用Parent Constraint 组件使一个游戏对象表现得好像它是另一个游戏对象的子对象,以用于定位和缩放,包括 RectTransform。

    【讨论】:

      猜你喜欢
      • 2023-03-10
      • 2019-02-14
      • 2017-10-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-27
      • 1970-01-01
      • 2017-11-14
      相关资源
      最近更新 更多