void Start() { if (projectionManager == null) { projectionManager = GameObject.FindObjectOfType <RATProjectionManager>(); } if (projectionManager != null) { projectionManager.RegisterUser(this); } //Code assumes that this script is added to the camera GO cameraGO = this.gameObject; cameraGO.transform.localPosition = new Vector3(); targetRGBTexture = new RenderTexture(texWidth, texHeight, 0, RenderTextureFormat.ARGBFloat, RenderTextureReadWrite.Default); targetRGBTexture.filterMode = FilterMode.Trilinear; targetRGBTexture.autoGenerateMips = true; targetRGBTexture.depth = 24; targetRGBTexture.Create(); rectReadRT = new Rect(0, 0, texWidth, texHeight); depthMeshes = GameObject.FindObjectsOfType <RATDepthMesh>(); initialized = true; }
void Start() { meshFilter = gameObject.AddComponent <MeshFilter>(); meshRenderer = gameObject.AddComponent <MeshRenderer>(); Shader unlitShader = Shader.Find("Unlit/Texture"); meshMat = new Material(unlitShader); debugPlaneM = new Mesh(); meshFilter.hideFlags = HideFlags.HideInInspector; meshRenderer.hideFlags = HideFlags.HideInInspector; meshMat.hideFlags = HideFlags.HideInInspector; if (projectionManager == null) { projectionManager = GameObject.FindObjectOfType <RATProjectionManager>(); } if (projectionManager != null) { projectionManager.RegisterUser(this); } //Code assumes that this script is added to the camera GO cameraGO = this.gameObject; cam = this.GetComponent <Camera>(); if (cam == null) { cam = gameObject.AddComponent <Camera>(); } cam.hideFlags = HideFlags.HideInInspector; // | HideFlags.HideInHierarchy cam.rect = new Rect(0, 0, 1, 1); cam.enabled = false; //important to disable this camera as we will be calling Render() directly. cam.aspect = texWidth / texHeight; cameraGO.transform.localPosition = new Vector3(); targetRGBTexture = new RenderTexture(texWidth, texHeight, 0, RenderTextureFormat.ARGBFloat, RenderTextureReadWrite.Default); targetRGBTexture.filterMode = FilterMode.Trilinear; targetRGBTexture.autoGenerateMips = true; targetRGBTexture.depth = 24; targetRGBTexture.Create(); rectReadRT = new Rect(0, 0, texWidth, texHeight); depthMeshes = GameObject.FindObjectsOfType <RATDepthMesh>(); initialized = true; }