Unity获取屏幕指定坐标的像素颜色

IEnumerator CaptureScreenshot()
    {
        //只在每一帧渲染完成后才读取屏幕信息
        yield return new WaitForEndOfFrame();

        Texture2D m_texture = new Texture2D(Screen.width, Screen.height, TextureFormat.RGB24, false);
        // 读取Rect范围内的像素并存入纹理中
        m_texture.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0);
        // 实际应用纹理
        m_texture.Apply();

        Color color = m_texture.GetPixel((int)Input.mousePosition.x, (int)Input.mousePosition.y);

}
posted @   哒哒哒~~~  阅读(401)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 单元测试从入门到精通
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律

阅读目录(Content)

此页目录为空

点击右上角即可分享
微信分享提示