当前位置: 首页>>代码示例>>C#>>正文


C# UIWidget.CalculateBounds方法代码示例

本文整理汇总了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));
    }
开发者ID:10people,项目名称:UnityLibrary,代码行数:20,代码来源:UIScrollView.cs

示例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;
        }
    }
开发者ID:10people,项目名称:UnityLibrary,代码行数:34,代码来源:UIScrollView.cs


注:本文中的UIWidget.CalculateBounds方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。