Unity3D中动态修改RectTransform的值
发布日期:2021-05-10 09:22:41 浏览次数:36 分类:精选文章

本文共 3026 字,大约阅读时间需要 10 分钟。

���������Unity UI���������������������RectTransform

���������������������RectTransform���������������Unity UI���������������������������������������������������������������RectTransform���������������������������������������������������������������������������������������������offsetMin���offsetMax������������������������������������������RectTransform������������������������

���������������������

���������������������������UI������������������������������RectTransform���������������������������������������������������������left���right���top���bottom��������������� UI���������������������������������������������������������������RectTransform������������������offset���������������������������������������������������������

offsetMin ��� offsetMax ���������

offsetMin���offsetMax������������RectTransform������������������������������������������������������������������������

  • offsetMin������������RectTransform���������������������������������������left���bottom���
  • offsetMax���������������������������������������������right���top������������������������������Anchors������������������1���1���������������������������������������������������������������

������������������ RectTransform ������

������������������������������������������RectTransform���������������������������������������������������

1. ������ RectTransform ��� top ��� right

��������������������������������� UI ���������������������������������������������

GetComponent
().offsetMax = new Vector2(left, top);

���������left���top������������RectTransform���������������������������������������������������������������������������������������������

2. ������ RectTransform ��� bottom ��� left

���������������������������������������������������������������������������

GetComponent
().offsetMin = new Vector2(right, bottom);

���������������������������������������������������������������������������������������

3. ������ RectTransform ������������������

��������������� RectTransform ���������������������������������������������������������

GetComponent
().sizeDelta = new Vector2(width, height);

���������width���height������������RectTransform������������������������������������������������������������������RectTransform���������������������

4. ������ RectTransform ���������

������������������������RectTransform���������������������������������������������

GetComponent
().anchoredPosition3D = new Vector3(posx, posy, posz);
GetComponent
().anchoredPosition = new Vector2(posx, posy);

���������������������������������RectTransform���������������������������������������anchoredPosition3D������������x���y������������������z���������������������������3D������������������������anchoredPosition������������2D���������������������

������

������������������������������������������������������������������RectTransform���������������������������������������������������������������������������������������������RectTransform������������������������������������������������������UI���������

上一篇:Unity3D实现点击按钮本身获取按钮所包含的文本内容且显示出来
下一篇:Untiy3D使用HighlightingSystem插件实现鼠标移动到物体物体高亮效果

发表评论

最新留言

关注你微信了!
[***.104.42.241]2025年04月07日 19时25分11秒

关于作者

    喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!

推荐文章