这个是我在使用UGUI中最蛋疼的一个属性,它明明就在那里,但是你却无法调用.....
所以所以所以,我查了和试了它的好多方法,终于解决了......希望对大家有所帮助
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 () {
// max.y返回的偏移量是个负数,所以需要乘以-1
Debug.Log("Top" + ":" + mySprite.offsetMax.y * -1);
Debug.Log("Bottom" + ":" + mySprite.offsetMin.y );
}
}