【Unity】UGUI中RectTransform中Top和Bottom的设置,宽和高的设置,以及postion和锚点的设置
来源:互联网 发布:linux里sort怎么用 编辑:程序博客网 时间:2024/06/14 06:31
UGUI中RectTransform中Top和Bottom的设置,宽和高的设置,以及postion和锚点的设置
using UnityEngine;using System.Collections;using UnityEngine.UI;/// <summary>/// 脚本位置:UGUI的图片/// </summary>public class test : MonoBehaviour{// 你的图片private RectTransform mySprite;void Start (){mySprite = gameObject.GetComponent<RectTransform> ();}void Update (){// 1.图片的Top设置为100(偏移的Max是负数)GetComponent<RectTransform> ().offsetMax = new Vector2 (GetComponent<RectTransform> ().offsetMax.x, -100);// 2.图片的Bottom设置为120GetComponent<RectTransform> ().offsetMin = new Vector2 (GetComponent<RectTransform> ().offsetMin.x, 120);// 3.改变RectTransform的宽和高(注:测试的时候锚点中不要选择带蓝色线的适配方式,那样会被拉伸的)GetComponent<RectTransform> ().sizeDelta = new Vector2 (100, 200);// 4.改变RectTransform的postion(x,y,z)GetComponent<RectTransform> ().anchoredPosition3D = new Vector3 (70,80, 90);// 5.改变锚点的位置GetComponent<RectTransform> ().anchoredPosition = new Vector2 (posx, posy);}}
0 0
- 【Unity】UGUI中RectTransform中Top和Bottom的设置,宽和高的设置,以及postion和锚点的设置
- Unity UGUI 的RectTransform参数的设置
- Unity UGUI 的RectTransform参数的设置
- 【Unity】UGUI怎么计算RectTransform中的Top和Bottom的值
- Unity3D-在代码中设置RectTransform的锚点、位置
- 在CSS中span标签设置padding-top/bottom以及margin-top/bottom无效的解决方法
- Android中在代码中设置控件的宽和高
- 设置组件的长和宽 LayoutParams以及获得屏幕的宽和高
- css中定位position、偏移top,bottom,left,right和高宽度设置问题
- Activity设置全屏以及Android获得屏幕的宽和高
- Activity设置全屏以及Android获得屏幕的宽和高
- Activity设置全屏以及Android获得屏幕的宽和高
- Activity设置全屏以及Android获得屏幕的宽和高
- Activity设置全屏以及Android获得屏幕的宽和高
- Activity设置全屏以及获得屏幕的宽和高
- Android修改AlertDialog宽和高以及设置AlertDialog的背景
- java代码设置布局的宽和高
- Android中如何在代码中设置View的宽和高
- java基本类型和包装器类【转】
- Transmission Strategy for Error Resilent
- 简单理解Socket
- srm 547
- GET和POST有什么区别?
- 【Unity】UGUI中RectTransform中Top和Bottom的设置,宽和高的设置,以及postion和锚点的设置
- EM算法简单理解
- 安卓:service,AID通信,有服务端和客户端的
- C++进阶学习——单例模式的实现
- 黑马程序员----C 语言学习笔记之结构体数组,指针,嵌套的使用
- Android系统栏相关(SystemBar)
- 证明方法------杂谈
- DoTween 一:< SetEase —— 渐变曲线 >
- iOS开发工具——网络封包分析工具Charles