当前位置: 首页 > news >正文

网站基础知识四川确诊感染最新消息

网站基础知识,四川确诊感染最新消息,手游代理免费平台,百度网站好评这个工具主要是用于动态生成UI的情况。项目中我们通过配置UI的锚点、位置以及大小(位置、大小都是通过蓝湖看到的),然后通过代码动态生成UI。 大部分情况下只要合理设置锚点,那么生成出来的UI就已经满足了适配的要求。 using UnityEngine;public static…

这个工具主要是用于动态生成UI的情况。项目中我们通过配置UI的锚点、位置以及大小(位置、大小都是通过蓝湖看到的),然后通过代码动态生成UI。
大部分情况下只要合理设置锚点,那么生成出来的UI就已经满足了适配的要求。

using UnityEngine;public static class RectTransUtility
{/// <summary>/// 左上 (0.0, 1.0)/// </summary>public static readonly Vector2 TopLeftVector = new(0.0f, 1.0f);/// <summary>/// 上中 (0.5, 1.0)/// </summary>public static readonly Vector2 TopCenterVector = new(0.5f, 1.0f);/// <summary>/// 右上 (1.0, 1.0)/// </summary>public static readonly Vector2 TopRightVector = new(1.0f, 1.0f);/// <summary>/// 左中 (0.0, 0.5)/// </summary>public static readonly Vector2 MiddleLeftVector = new(0.0f, 0.5f);/// <summary>/// 中心 (0.5, 0.5)/// </summary>public static readonly Vector2 MiddleCenterVector = new(0.5f, 0.5f);/// <summary>/// 右中 (1.0, 0.5)/// </summary>public static readonly Vector2 MiddleRightVector = new(1.0f, 0.5f);/// <summary>/// 左下 (0.0, 0.0)/// </summary>public static readonly Vector2 BottomLeftVector = new(0.0f, 0.0f);/// <summary>/// 下中 (0.5, 0.0)/// </summary>public static readonly Vector2 BottomCenterVector = new(0.5f, 0.0f);/// <summary>/// 右下 (1.0, 0.0)/// </summary>public static readonly Vector2 BottomRightVector = new(1.0f, 0.0f);/// <summary>/// 设置位置与大小/// </summary>public static void SetRTPosition(RectTransform rt, ERectTransAnchor anchor_pivot, float x, float y, float width, float height){//设置锚点和轴心点SetRTAnchorAndPivot(rt, anchor_pivot);switch (anchor_pivot){case ERectTransAnchor.TopLeft:rt.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, x, width);rt.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, y, height);return;case ERectTransAnchor.TopCenter:rt.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, y, height);rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, width);rt.anchoredPosition = new Vector2(x, rt.anchoredPosition.y);return;case ERectTransAnchor.TopRight:rt.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Right, x, width);rt.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, y, height);return;case ERectTransAnchor.MiddleLeft:rt.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, x, width);rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, height);rt.anchoredPosition = new Vector2(rt.anchoredPosition.x, y);return;case ERectTransAnchor.MiddleCenter:rt.sizeDelta = new Vector2(width, height);rt.anchoredPosition = new Vector2(x, y);return;case ERectTransAnchor.MiddleRight:rt.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Right, x, width);rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, height);rt.anchoredPosition = new Vector2(rt.anchoredPosition.x, y);return;case ERectTransAnchor.BottomLeft:rt.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, x, width);rt.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Bottom, y, height);return;case ERectTransAnchor.BottomCenter:rt.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Bottom, y, height);rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, width);rt.anchoredPosition = new Vector2(x, rt.anchoredPosition.y);return;case ERectTransAnchor.BottomRight:rt.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Right, x, width);rt.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Bottom, y, height);return;}Debug.LogWarning("[RectTransUtility.SetRTPosition] 暂不支持的锚点类型!");}/// <summary>/// 设置锚点和轴心点/// </summary>public static void SetRTAnchorAndPivot(RectTransform rt, ERectTransAnchor anchor_pivot){switch (anchor_pivot){case ERectTransAnchor.TopLeft:rt.anchorMin = TopLeftVector;rt.anchorMax = TopLeftVector;rt.pivot = TopLeftVector;return;case ERectTransAnchor.TopCenter:rt.anchorMin = TopCenterVector;rt.anchorMax = TopCenterVector;rt.pivot = TopCenterVector;return;case ERectTransAnchor.TopRight:rt.anchorMin = TopRightVector;rt.anchorMax = TopRightVector;rt.pivot = TopRightVector;return;case ERectTransAnchor.MiddleLeft:rt.anchorMin = MiddleLeftVector;rt.anchorMax = MiddleLeftVector;rt.pivot = MiddleLeftVector;return;case ERectTransAnchor.MiddleCenter:rt.anchorMin = MiddleCenterVector;rt.anchorMax = MiddleCenterVector;rt.pivot = MiddleCenterVector;return;case ERectTransAnchor.MiddleRight:rt.anchorMin = MiddleRightVector;rt.anchorMax = MiddleRightVector;rt.pivot = MiddleRightVector;return;case ERectTransAnchor.BottomLeft:rt.anchorMin = BottomLeftVector;rt.anchorMax = BottomLeftVector;rt.pivot = BottomLeftVector;return;case ERectTransAnchor.BottomCenter:rt.anchorMin = BottomCenterVector;rt.anchorMax = BottomCenterVector;rt.pivot = BottomCenterVector;return;case ERectTransAnchor.BottomRight:rt.anchorMin = BottomRightVector;rt.anchorMax = BottomRightVector;rt.pivot = BottomRightVector;return;}Debug.LogWarning("[RectTransUtility.SetRTAnchorAndPivot] 暂不支持的锚点类型!");}/// <summary>/// 设置背景填充/屏幕填充/// </summary>/// <param name="self"></param>/// <param name="left">离左边的距离(距离为正)</param>/// <param name="bottom">离底部的距离(距离为正)</param>/// <param name="right">离右边的距离(距离为负)</param>/// <param name="top">离顶部的距离(距离为负)</param>/// <returns></returns>public static RectTransform BgFill(this RectTransform self, float left = 0f, float bottom = 0f, float right = 0f, float top = 0f){self.anchorMin = RectTransUtility.BottomLeftVector;self.anchorMax = RectTransUtility.TopRightVector;self.offsetMin = new Vector2(left, bottom);self.offsetMax = new Vector2(right, top);return self;}/// <summary>/// 锚点类型/// </summary>public enum ERectTransAnchor{/// <summary>/// 左上/// </summary>TopLeft = 0,/// <summary>/// 上中/// </summary>TopCenter = 1,/// <summary>/// 右上/// </summary>TopRight = 2,/// <summary>/// 左中/// </summary>MiddleLeft = 3,/// <summary>/// 中心/// </summary>MiddleCenter = 4,/// <summary>/// 右中/// </summary>MiddleRight = 5,/// <summary>/// 左下/// </summary>BottomLeft = 6,/// <summary>/// 下中/// </summary>BottomCenter = 7,/// <summary>/// 右下/// </summary>BottomRight = 8}
}
http://www.yayakq.cn/news/734948/

相关文章:

  • 行业门户网站模板硬件开发设计
  • 邳州建设银行招聘网站郑州市装修公司哪家好
  • 茂县建设局网站挖掘关键词工具
  • 公司网站开发流程图wordpress固定链接设置404
  • 做网站什么前端框架方便智能网站建设维护
  • 印刷 网站源码页面模板 wordpress
  • 网站开发合同是否要交印花税wordpress linux 权限
  • 网站建设费用要摊销嘛安卓优化大师app
  • 在征婚网站上认识做期货山东seo优化
  • 什么人需要网站建设西宁做网站公司电话
  • 工业园区门户网站建设方案济南的互联网公司
  • 给分管领导网站建设情况汇报怎么写世界杯观看入口
  • 如何查看网站开发者安卓移动端开发
  • 闵行 网站建设公司今天昆明刚刚发生的新闻
  • 常德做网站的公司莱州网站建设多少钱
  • 动态ip怎么做网站你喜欢的公司网站
  • wordpress本地上传到网站做网站用什么代码
  • 地方门户网站赚钱中国城乡建设部网站首页
  • 电商网站开发 上海文化建设的名言警句
  • 全包胶衣网站青岛网站建设seo
  • 嘉峪关做网站网站建设语言什么语言
  • 咸阳市城市建设管理局网站六安seo网站推广报价
  • 青岛东橙网站建设重庆公司排行榜
  • 注册网站平台wordpress三栏主题
  • 网站建设公司 腾佳wordpress影视源码
  • 搭建网站 网页湖北建设信息网官网
  • 北京华兴森茂印刷网站建设项目想做网站怎么做
  • wordpress直接访问站点品牌宣传推广方案
  • 西安免费建网站制作淄博高效网站建设找哪家
  • wordpress本地网站网站建设属于哪种职位