Skip to content

Instantly share code, notes, and snippets.

@jackaperkins
Created September 21, 2016 11:30
Show Gist options
  • Save jackaperkins/cb786e93fa940145354a0c789e2dae19 to your computer and use it in GitHub Desktop.
Save jackaperkins/cb786e93fa940145354a0c789e2dae19 to your computer and use it in GitHub Desktop.
SyncPortalCamera.cs
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