35 lines
890 B
C#

using MMMaellon.LightSync;
using UdonSharp;
using UnityEngine;
using VRC.SDKBase;
using VRC.Udon;
[UdonBehaviourSyncMode(BehaviourSyncMode.Manual)]
public class CameraAnchor : UdonSharpBehaviour
{
[SerializeField] private float FOV = 60.0f;
[SerializeField] private float NearClippingPlane = 0.3f;
[SerializeField] private float FarClippingPlane = 1000.0f;
public void AttachCamera(Camera CameraComponent)
{
CameraComponent.gameObject.SetActive(true);
CameraComponent.transform.parent = transform;
CameraComponent.fieldOfView = FOV;
CameraComponent.nearClipPlane = NearClippingPlane;
CameraComponent.farClipPlane = FarClippingPlane;
CameraComponent.GetComponent<LightSync>().TeleportToLocalSpace(Vector3.zero, Quaternion.identity, true);
}
#if UNITY_EDITOR
private void OnDrawGizmos()
{
Gizmos.DrawIcon(transform.position, "CameraAnchor", true);
}
#endif
}