zoukankan      html  css  js  c++  java
  • 修改RectTransform的值

    用uGUI的时候。经常需要动态改变RectTransform的值,

    当选择不同的布局。你会发现这里的值是不同的

    有的left,botom。或者posx posy

    这时想改变就要通过对应的属性值了

    U3D 新UI系统UGUI 的recttransform一些参数的设置
    unity出了一套比之前好用的UI系统,但是也新出了RectTransform,PosX,PosY....,刚开始可能不知道怎么用代码去更改,但是经过许多的实验之后就会明白一些:


    1.改变RectTransform的top
    GetComponent<RectTransform>().offsetMax = new Vector2(GetComponent<RectTransform>().offsetMax.x, top);


    2.改变RectTransform的bottom
    GetComponent<RectTransform>().offsetMin = new Vector2(GetComponent<RectTransform>().offsetMin.x, bottom);


    3.改变RectTransform的width,height
    GetComponent<RectTransform>().sizeDelta = new Vector2(width, height);


    4.改变RectTransform的pos
    GetComponent<RectTransform>().anchoredPosition3D = new Vector3(posx,posy,posz);
    GetComponent<RectTransform>().anchoredPosition = new Vector2(posx,posy);

  • 相关阅读:
    机器学习系列(4) 线性回归
    MYSQL系列(5) 电商常用指标查询
    MYSQL系列(4) 关于时间函数的一些写法
    快速排序
    选择排序
    希尔排序
    直接插入排序
    冒泡排序
    Java修饰符大汇总
    字符串实现大数的相加
  • 原文地址:https://www.cnblogs.com/nsky/p/5045201.html
Copyright © 2011-2022 走看看