首先要获取到 Image 的RectTransform组件, 再修改其中的属性
void Awake(){ gameObject.GetComponent<RectTransform>().sizeDelta=new Vector2(200f,30f); }
图片的原始尺寸是 100 X100
设置面板信息引导线条
private void ShowImageLine(Transform obj){line.gameObject.SetActive(true);distance = new Vector2(message.position.x + message.sizeDelta.x/2, obj.position.y + obj.GetComponent<RectTransform>().sizeDelta.y); line.GetComponent<RectTransform>().position = distance;line.GetComponent<RectTransform>().sizeDelta = new Vector2(obj.transform.position.x - distance.x, 30f);}