本文整理汇总了C#中UIWidget.CalculateBounds方法的典型用法代码示例。如果您正苦于以下问题:C# UIWidget.CalculateBounds方法的具体用法?C# UIWidget.CalculateBounds怎么用?C# UIWidget.CalculateBounds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UIWidget
的用法示例。
在下文中一共展示了UIWidget.CalculateBounds方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetWidgetValueRelativeToScrollView
/// <summary>
/// Added by liangxiao, calculate widget value(-1 -- 2) relative to ScrollView, widget must be scroll view's child.
/// </summary>
/// <param name="widget">widget must be scroll view's child</param>
/// <returns>value of x, value of y</returns>
public Vector2 GetWidgetValueRelativeToScrollView(UIWidget widget)
{
if (mPanel == null) return new Vector2(-100, -100);
Bounds bound = widget.CalculateBounds();
//Get bound relative to scroll view.
Transform current = widget.transform;
while (current != transform)
{
bound.center += current.localPosition;
current = current.parent;
}
return new Vector2(GetBoundValueRelativeToScrollView(true, bound), GetBoundValueRelativeToScrollView(false, bound));
}
示例2: SetWidgetValueRelativeToScrollView
/// <summary>
/// Added by liangxiao, set scroll view value(0 - 1) by specific widget, not whole bounds.
/// </summary>
/// <param name="widget">specific widget</param>
/// <param name="value"></param>
public void SetWidgetValueRelativeToScrollView(UIWidget widget, float value)
{
if (movement != Movement.Horizontal && movement != Movement.Vertical)
{
Debug.LogError("Cannot set widget value relative to scroll view cause scroll view not be single clip, contact to Liangxiao if you don't know what to do.");
return;
}
Bounds bound = widget.CalculateBounds();
//Get bound relative to scroll view.
Transform current = widget.transform;
while (current != transform)
{
bound.center += current.localPosition;
current = current.parent;
}
if (!mIgnoreCallbacks)
{
mIgnoreCallbacks = true;
mCalculatedBounds = false;
Vector2 pv = NGUIMath.GetPivotOffset(contentPivot);
float x = (movement == Movement.Horizontal) ? value : pv.x;
float y = (movement == Movement.Vertical) ? value : 1f - pv.y;
SetDragManualAmount(x, y, bound, false);
UpdateScrollbars(true);
mIgnoreCallbacks = false;
}
}