Beispiel #1
0
        /// <summary>
        /// 按资源的Rect设置拉伸的坐标
        /// </summary>
        /// <param name="rectTransform"></param>
        /// <param name="baseRect"></param>
        /// <param name="resourceDic"></param>
        public static void SetRectFromResource(this RectTransform rectTransform, Rect baseRect, ResourceDic resourceDic = null)
        {
            var rect = new Rect(Vector2.zero, baseRect.size);

            if (resourceDic != null)
            {
                LayerImportUtil.UpdateRectFromResourceDic(ref rect, resourceDic);
            }
            rect = ParamAnalysisTool.PsRectToUnityRect(baseRect.size, rect);
            LayerImportUtil.SetRectTransform(rect, rectTransform);
            LayerImportUtil.SetCustomAnchor(baseRect.size, rectTransform);
        }
Beispiel #2
0
        /// <summary>
        /// 按资源的Rect设置拉伸的坐标
        /// </summary>
        /// <param name="rectTransform"></param>
        /// <param name="rootRect"></param>
        /// <param name="baseRect"></param>
        /// <param name="resourceDic"></param>
        public static void SetRectFromResource(this RectTransform rectTransform, Rect rootRect, Rect baseRect, ResourceDic resourceDic = null)
        {
            var rect = new Rect(Vector2.zero, baseRect.size);

            if (resourceDic != null)
            {
                if (LayerImportUtil.UpdateRectFromResourceDic(ref rect, resourceDic))
                {
                    //得到相对于BaseRect的相对值
                    rect = new Rect(rect.x + rootRect.x - baseRect.x, rect.y + rootRect.y - baseRect.y, rect.width, rect.height);
                }
            }
            rect = ParamAnalysisTool.PsRectToUnityRect(baseRect.size, rect);
            LayerImportUtil.SetRectTransform(rect, rectTransform);
            LayerImportUtil.SetCustomAnchor(baseRect.size, rectTransform);
        }