using System.Collections; using UnityEngine; using UnityEngine.Networking; public class WallArt : MonoBehaviour { public GameObject outsideCameraPrefab; public Transform window; private Camera outsideCameraInstance; public MeshRenderer meshRenderer; private OVRCameraRig ovrCameraRig; private RenderTexture renderTexture; private Material material; // Start is called before the first frame update void Start() { var randomNumber = Random.Range(10000, 99999); MarcsWebLogger.Log($"{randomNumber}-WallArt_start"); renderTexture = new RenderTexture(256, 256, 0) { dimension = UnityEngine.Rendering.TextureDimension.Tex2D, wrapMode = TextureWrapMode.Clamp, filterMode = FilterMode.Bilinear, enableRandomWrite = false, useDynamicScale = false, useMipMap = false, // true testen depthStencilFormat = UnityEngine.Experimental.Rendering.GraphicsFormat.D24_UNorm_S8_UInt, }; GameObject camera = Instantiate(outsideCameraPrefab, transform.position, Quaternion.identity); outsideCameraInstance = camera.GetComponent(); // Attempt to set the target texture outsideCameraInstance.targetTexture = renderTexture; material = new Material(Shader.Find("Standard")); material.mainTexture = renderTexture; meshRenderer.material = material; ovrCameraRig = FindObjectOfType(); MarcsWebLogger.Log($"{randomNumber}-WallArt_end"); } // Update is called once per frame void Update() { // Check if the cameraRig is assigned if (ovrCameraRig == null) return; outsideCameraInstance.transform.position = ovrCameraRig.centerEyeAnchor.position; outsideCameraInstance.transform.LookAt(window); } }