创建网站主题在哪里,免费做外贸的网站平台,建设部网站监理工程师查询,福州市建网站公司拿来吧你~ #x1f9aa;功能介绍#x1f32d;Demo #x1f9aa;功能介绍
#x1f4a1;不通过Texture2D 而是通过ComputerShader 提取到RenderTexture的像素值#xff0c;效率有提升哦#xff01; #x1f4a1;通过扩展方法调用#xff0c;方便快捷#xff1a;xxxRT.G… 拿来吧你~ 功能介绍Demo 功能介绍
不通过Texture2D 而是通过ComputerShader 提取到RenderTexture的像素值效率有提升哦 通过扩展方法调用方便快捷xxxRT.GetPixel 传送门
Demo
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.InputSystem;
namespace ZYF
{public class GetRTPixelDemo : MonoBehaviour{public RenderTexture rt;public UnityEventColor onGetColor;private void Update(){
#if !ENABLE_INPUT_SYSTEMvar mPos Input.mousePosition;
#elsevar mPos Mouse.current.position.value;
#endifvar pos new Vector2Int((int)mPos.x, (int)mPos.y);var color rt.GetPixel(new GetRTPixelExtension.RequestInfo(pos));onGetColor?.Invoke(color);}private void OnDestroy(){rt?.EndGetPixel();}}}