Created
September 21, 2016 11:30
-
-
Save jackaperkins/cb786e93fa940145354a0c789e2dae19 to your computer and use it in GitHub Desktop.
SyncPortalCamera.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
public class SyncPortalCamera : MonoBehaviour { | |
public GameObject axisA, cameraA, axisB, renderCamera; | |
public Texture renderTarget; | |
// Use this for initialization | |
void Start () { | |
//cameraA.GetComponent<Camera>().main | |
renderCamera.GetComponent<Camera>().targetTexture = (RenderTexture) renderTarget; | |
renderTarget.width = Screen.width; | |
renderTarget.height = Screen.height; | |
} | |
// Update is called once per frame | |
void OnPreRender () { | |
Vector3 offset = (cameraA.transform.position - axisA.transform.position); | |
renderCamera.transform.position = axisB.transform.position + offset; | |
renderCamera.transform.rotation = cameraA.transform.rotation; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment