-
Notifications
You must be signed in to change notification settings - Fork 0
/
VRCCamController.cs
53 lines (41 loc) · 965 Bytes
/
VRCCamController.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using UnityEngine;
public class VRCCamController : MonoBehaviour
{
[SerializeField]
private Sprite imageSprite;
[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 = imageSprite;
}
}