Canvas canvas;
public GameObject image;
void Start()
{
canvas = GameObject.Find("Canvas").GetComponent<Canvas>();
image.GetComponent<Image>().enabled=false;
}
void Update(){
if(Input.GetMouseButtonDown(0)){
image.GetComponent<Image>().enabled = true;
Vector2 pos;
if (RectTransformUtility.ScreenPointToLocalPointInRectangle(canvas.transform as RectTransform, Input.mousePosition, canvas.worldCamera, out pos))
{
image.GetComponent<RectTransform>().anchoredPosition = pos;
}
}
}
UGUI中点击鼠标绘制图片
最新推荐文章于 2024-06-18 13:30:26 发布