您当前的位置: 首页 >  unity

unity工具人

暂无认证

  • 2浏览

    0关注

    205博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

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

unity工具人 发布时间:2021-05-30 09:40:45 ,浏览量:2

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);

}
关注
打赏
1656671177
查看更多评论
立即登录/注册

微信扫码登录

0.0353s