37 lines
764 B
C#
37 lines
764 B
C#
using DragonLi.Frame;
|
|
using DragonLi.Core;
|
|
using UnityEngine;
|
|
|
|
namespace InfiniteShooting
|
|
{
|
|
public class CanvasFaceToCamera : MonoBehaviour
|
|
{
|
|
private Transform mainCamera = null;
|
|
public Transform CameraTrans
|
|
{
|
|
get
|
|
{
|
|
if (mainCamera == null)
|
|
mainCamera = World.GetMainCamera();
|
|
|
|
return mainCamera;
|
|
}
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
UpdateRotation();
|
|
}
|
|
|
|
private void UpdateRotation()
|
|
{
|
|
if (CameraTrans)
|
|
{
|
|
transform.rotation = Quaternion.LookRotation((transform.position - CameraTrans.position).ReflectVectorXOZ());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|