/** * Copyright(c) Live2D Inc. All rights reserved. * * Use of this source code is governed by the Live2D Open Software license * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html. */ using UnityEngine; namespace Live2D.Cubism.Samples.LookAt { /// /// Forces a to face a camera. /// public class Billboarder : MonoBehaviour { /// /// Camera to face. /// [SerializeField] public Camera CameraToFace; #region Unity Event Handling /// /// Called by Unity. Updates facing. /// private void Update() { if (CameraToFace.orthographic) { transform.LookAt(transform.position - CameraToFace.transform.forward, CameraToFace.transform.up); } else { transform.LookAt(CameraToFace.transform.position, CameraToFace.transform.up); } } #endregion } }