6 public Material material;
7 public Transform target;
8 public bool undistorted =
true;
9 public bool cropped =
true;
15 var source = SteamVR_TrackedCamera.Source(undistorted);
19 if (!source.hasCamera)
26 material.mainTexture = null;
30 var source = SteamVR_TrackedCamera.Source(undistorted);
36 var source = SteamVR_TrackedCamera.Source(undistorted);
37 var texture = source.texture;
48 material.mainTexture = texture;
51 var aspect = (float)texture.width / texture.height;
58 var bounds = source.frameBounds;
59 material.mainTextureOffset =
new Vector2(bounds.uMin, bounds.vMin);
61 var du = bounds.uMax - bounds.uMin;
62 var dv = bounds.vMax - bounds.vMin;
63 material.mainTextureScale =
new Vector2(du, dv);
65 aspect *= Mathf.Abs(du / dv);
69 material.mainTextureOffset = Vector2.zero;
70 material.mainTextureScale =
new Vector2(1, -1);
73 target.localScale =
new Vector3(1, 1.0f / aspect, 1);
76 if (source.hasTracking)
78 var t = source.transform;
79 target.localPosition = t.pos;
80 target.localRotation = t.rot;