Skip to content

Instantly share code, notes, and snippets.

@cubed2d
Created February 7, 2013 19:00
Show Gist options
  • Save cubed2d/4733250 to your computer and use it in GitHub Desktop.
Save cubed2d/4733250 to your computer and use it in GitHub Desktop.
// attach this to a camera. It sets the sort mode so 2D object are rendered correctly with a perspective camera.
public class CameraSortModeSetter : MonoBehaviour
{
void Update()
{
if (camera != null && camera.transparencySortMode != TransparencySortMode.Orthographic)
camera.transparencySortMode = TransparencySortMode.Orthographic;
}
}
// atach this to child cameras in the camera stack.
public class CameraSettingSynch : MonoBehaviour
{
private Camera parentCamera;
private Camera myCamera;
// Use this for initialization
void Start ()
{
parentCamera = transform.parent.gameObject.camera;
myCamera = camera; // faster if we store this off..
}
// Update is called once per frame
void Update ()
{
myCamera.fov = parentCamera.fov;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment