Modifying the value of a recttransform

Source: Internet
Author: User

When you use the Ugui. It is often necessary to dynamically change the value of Recttransform,

When you select a different layout. You'll find that the values here are different.

Some left,botom. or Posx posy.

When you want to change, you pass the corresponding attribute value.

U3d settings for Recttransform Some parameters of the new UI system Ugui
Unity has a UI system that works better than before, but it's also new to the recttransform,posx,posy .... You may not know how to change the code at first, but after a lot of experimentation you will understand something:


1. Change the top of Recttransform
Getcomponent<recttransform> (). Offsetmax = new Vector2 (getcomponent<recttransform> (). offsetMax.x, top);


2. Change the bottom of recttransform
Getcomponent<recttransform> (). offsetmin = new Vector2 (getcomponent<recttransform> (). OffsetMin.x, bottom);


3. Change the width,height of Recttransform
Getcomponent<recttransform> (). Sizedelta = new Vector2 (width, height);


4. Change the pos of Recttransform
Getcomponent<recttransform> (). anchoredposition3d = new Vector3 (Posx,posy,posz);
Getcomponent<recttransform> (). anchoredposition = new Vector2 (posx,posy);

Modifying the value of a recttransform

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.