• 2024-07-01Unity 导航路线生成,小地图同步映射, 经过以后地图与小地图删除点位(点击小地图控制导航以及点击场景导航都会有路径点和路径点图标)
    效果:(如下图所示)操作方法:搭建小地图UI截取图片创建地面挂载如下代码:usingSystem.Collections.Generic;usingUnityEngine;usingUnityEngine.UI;[RequireComponent(typeof(MeshFilter),typeof(MeshCollider),typeof(MeshRenderer))]publicclassMap:Mo
  • 2023-08-01RectTransform操作
    RectTransform操作一、改变RectTransform的大小三种方法//1.直接对sizeDelta属性进行赋值,其中X和Y可以对应理解成width和height。sizeDelta的具体含义:若achors是一个点的话则代表宽高,否则为到锚点的距离rectTransform.sizeDelta=newVector2(200,200);//2.使用SetSizeWith
  • 2023-07-30RectTransform的两个设置大小的api
     varrtf=GetComponent<RectTransform>();rtf.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal,200);SetSizeWithCurrentAnchors不会改变anchorMin和anchorMax设置大小会根据pivot的值,往两边扩充 varrtf=GetComponent<RectTransform>();rtf.SetInset
  • 2023-05-29TS装饰器
    /***自动绑定的装饰器**@export*@param{string}[bindName]*@return{*}*/exportfunctionautobind(bindName?:string){returnfunction(target:object,properkey:string){bindName=bindName!=null?bindName:(properkey[0]==
  • 2023-04-15Unity锚点(Anchor)
    如果一个RectTransform的parent也是RectTransform,那么孩子RectTransform可以通过各种方式锚定在父RectTransform。AnchorMin对应左下角的锚点,AnchorMax对应右上角的锚点。此时显示了PosXPosY字段是因为4个锚点重合,如果锚点不重合,那么可能显示LeftRight,代表到左边锚点和右
  • 2023-03-15UGUI UIBehaviour.OnRectTransformDimensionsChange()
     1.当此脚本所在的RectTransform维度发生变化时调用的函数(在Awake方法之前会调用一次)。  2.维度发生变化也就是RectTransform下列属性发生变化:大小:Width、Heigh
  • 2022-12-02RectTransform
      localPosition中心点对于父节点中心点  anchoredPosition  offsetMaxoffsetMinsizeDeltarect.positionrect.size
  • 2022-11-29UGUI源码解析(二十一)LayoutRebuilder
    LayoutRebuilderGraphic是通过MarkLayoutForRebuild这个静态方法标记自己需要重建的。MarkLayoutForRebuild方法找到父对象中最近的ILayoutGroup类型的组件layoutRoot,并为其
  • 2022-11-24关于代码添加ui控件代码修改recttransform的问题探索
    问题起因:我通过代码添加了预制体发现位置不对,看不见了,通过检查器看到x和y为-115,-351,发现修改pos没有任何作用U7JZ{0~OM61W`J_5M7DKVC3.png但是发现并没有