Skip to content

Instantly share code, notes, and snippets.

@kmnk
Created March 31, 2019 08:30
Show Gist options
  • Save kmnk/534ce51a02ef067b32192f71269aefab to your computer and use it in GitHub Desktop.
Save kmnk/534ce51a02ef067b32192f71269aefab to your computer and use it in GitHub Desktop.
VRCCamController
using UnityEngine;
public class VRCCamController : MonoBehaviour
{
[SerializeField]
private Sprite sprite;
[SerializeField]
[Range(.1f, 10f)]
private float size = 5f;
private Transform vrcCamTransform;
private Camera vrcCam;
static readonly string vrcCamName = "/VRCCam";
void SetupCamera()
{
}
void Update()
{
if (vrcCamTransform == null)
{
var t = transform.Find(vrcCamName);
vrcCamTransform = t;
if (t != null)
{
transform.SetParent(t);
transform.localPosition = new Vector3(0f, 0f, 100f);
transform.localRotation = Quaternion.identity;
t.localPosition = new Vector3(0f, 0f, -100f);
vrcCam = t.GetComponent<Camera>();
vrcCam.orthographic = true;
}
}
else
{
vrcCam.orthographicSize = size;
}
}
void Awake()
{
var spriteRenderer = gameObject.AddComponent<SpriteRenderer>();
spriteRenderer.sprite = sprite;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment