live2D (sdk가 6.5 미지원으로 sprite로 대응)
This commit is contained in:
43
Assets/Live2D/Cubism/Samples/LookAt/Billboarder.cs
Normal file
43
Assets/Live2D/Cubism/Samples/LookAt/Billboarder.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* 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
|
||||
{
|
||||
/// <summary>
|
||||
/// Forces a <see cref="GameObject"/> to face a camera.
|
||||
/// </summary>
|
||||
public class Billboarder : MonoBehaviour
|
||||
{
|
||||
/// <summary>
|
||||
/// Camera to face.
|
||||
/// </summary>
|
||||
[SerializeField] public Camera CameraToFace;
|
||||
|
||||
#region Unity Event Handling
|
||||
|
||||
/// <summary>
|
||||
/// Called by Unity. Updates facing.
|
||||
/// </summary>
|
||||
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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user