本文整理汇总了C#中UIRect.UpdateAnchors方法的典型用法代码示例。如果您正苦于以下问题:C# UIRect.UpdateAnchors方法的具体用法?C# UIRect.UpdateAnchors怎么用?C# UIRect.UpdateAnchors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UIRect
的用法示例。
在下文中一共展示了UIRect.UpdateAnchors方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MoveRect
/// <summary>
/// Adjust the rectangle's position using the specified local delta coordinates.
/// </summary>
static public void MoveRect (UIRect rect, float x, float y)
{
int ix = Mathf.FloorToInt(x + 0.5f);
int iy = Mathf.FloorToInt(y + 0.5f);
Transform t = rect.cachedTransform;
t.localPosition += new Vector3(ix, iy);
int anchorCount = 0;
if (rect.leftAnchor.target)
{
++anchorCount;
rect.leftAnchor.absolute += ix;
}
if (rect.rightAnchor.target)
{
++anchorCount;
rect.rightAnchor.absolute += ix;
}
if (rect.bottomAnchor.target)
{
++anchorCount;
rect.bottomAnchor.absolute += iy;
}
if (rect.topAnchor.target)
{
++anchorCount;
rect.topAnchor.absolute += iy;
}
#if UNITY_EDITOR
NGUITools.SetDirty(rect);
#endif
// If all sides were anchored, we're done
if (anchorCount != 0) rect.UpdateAnchors();
}
示例2: MoveRect
public static void MoveRect(UIRect rect, float x, float y)
{
int num = Mathf.FloorToInt(x + 0.5f);
int num2 = Mathf.FloorToInt(y + 0.5f);
Transform cachedTransform = rect.cachedTransform;
cachedTransform.localPosition += new Vector3((float)num, (float)num2);
int num3 = 0;
if (rect.leftAnchor.target)
{
num3++;
rect.leftAnchor.absolute += num;
}
if (rect.rightAnchor.target)
{
num3++;
rect.rightAnchor.absolute += num;
}
if (rect.bottomAnchor.target)
{
num3++;
rect.bottomAnchor.absolute += num2;
}
if (rect.topAnchor.target)
{
num3++;
rect.topAnchor.absolute += num2;
}
if (num3 != 0)
{
rect.UpdateAnchors();
}
}