public static void LoadOnce(AirVRProfileBase profile, AirVRCameraBase camera) { if (_instance == null) { GameObject go = new GameObject("AirVRClient"); go.AddComponent <AirVRClient>(); Assert.IsTrue(_instance != null); _instance._profile = profile; if (profile.useSeperateVideoRenderTarget) { _instance._videoFrameRenderer = new AirVRVideoFrameRenderer(go, profile, camera); } onairvr_SetProfile(JsonUtility.ToJson(profile.GetSerializable())); } }
public AirVRVideoFrameRenderer(GameObject owner, AirVRProfileBase profile, AirVRCameraBase camera) { _camera = camera.GetComponent <Camera>(); _cameraTransform = camera.transform; float[] videoScale = profile.videoScale; Mesh mesh = new Mesh(); mesh.vertices = new Vector3[] { new Vector3(-videoScale[0], videoScale[1], Depth), new Vector3(videoScale[0], videoScale[1], Depth), new Vector3(-videoScale[0], -videoScale[1], Depth), new Vector3(videoScale[0], -videoScale[1], Depth) }; mesh.uv = new Vector2[] { new Vector2(0.0f, 0.0f), new Vector2(1.0f, 0.0f), new Vector2(0.0f, 1.0f), new Vector2(1.0f, 1.0f) }; mesh.triangles = new int[] { 0, 1, 2, 2, 1, 3 }; _meshFilter = owner.GetComponent <MeshFilter>(); if (_meshFilter == null) { _meshFilter = owner.AddComponent <MeshFilter>(); } _meshFilter.mesh = mesh; _meshFilter.mesh.UploadMeshData(true); _renderer = owner.GetComponent <MeshRenderer>(); if (_renderer == null) { _renderer = owner.AddComponent <MeshRenderer>(); } _renderer.material = new Material(Shader.Find("onAirVR/Video frame on far clip plane")); _renderer.enabled = false; }