一直有个想法,如果手机只作为VR显示端,那么用PC来运行VR程序,传输实时画面到手机不就可以了。今天就来实验下,看看方案是否可行。
首先创建一个Render Texture,用于将相机渲染到该目标。
创建以下脚本,实时获取Render Texture中的数据:
using UnityEngine;
using UnityEngine.UI;
public class GetCameraTexture : MonoBehaviour
{
Camera cam;
RenderTexture rt;
public RawImage ri;
public Text text;
void Start()
{
cam = GetComponent();
rt = cam.targetTexture;
rt.vrUsage = VRTextureUsage.TwoEyes;
t2d = new Texture2D(rt.width, rt.height, TextureFormat.ARGB32, false, true);
ri.texture = t2d;
}
const float MB = 1024 * 1024;
float max = 0;
float min = float.MaxValue;
void OnPostRender()
{
GetRTPixels(rt);
byte