29 lines
661 B
C#
29 lines
661 B
C#
using System;
|
|
using UnityEngine;
|
|
|
|
namespace VRUIP
|
|
{
|
|
public class UIFX : MonoBehaviour
|
|
{
|
|
public bool alwaysFacePlayer;
|
|
|
|
private void Update()
|
|
{
|
|
if (alwaysFacePlayer)
|
|
{
|
|
LookAtPlayer();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Rotate this canvas to be facing the player.
|
|
/// </summary>
|
|
private void LookAtPlayer()
|
|
{
|
|
var direction = transform.position - VRUIPManager.instance.mainCamera.transform.position;
|
|
var lookRotation = Quaternion.LookRotation(direction);
|
|
transform.rotation = lookRotation;
|
|
}
|
|
}
|
|
}
|