Unity-绘制图片
程序员文章站
2022-03-26 15:56:07
...
在 Game 窗口下,通过鼠标左键单机绘制图片
//==========================
// - FileName: DrawPicture.cs
// - Created: true.
// - CreateTime: 2020/05/27 17:56:10
// - Email: [email protected]
// - Region: China WUHAN
// - Description:
//==========================
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DrawPicture : MonoBehaviour
{
//图片
public Texture img;
//储存鼠标的位置坐标
private Vector2 pos;
void OnGUI()
{
//鼠标左击,获取当前鼠标的位置
if (Input.GetMouseButton(0))
{
pos = Input.mousePosition;
}
//绘制图片
GUI.DrawTexture(new Rect(pos.x, Screen.height - pos.y, 100, 100), img);
}
}