Loading files
4e10c4f05This file is pinned to the selected release. Download the original to open it in your design tool.
using Leap.Unity.Interaction;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Leap.Unity.Apps.Launcher {
public class FacingCameraOnlyButton : MonoBehaviour {
public InteractionButton button;
private void Reset() {
findButton();
}
private void OnValidate() {
findButton();
}
private void findButton() {
if (button == null) button = GetComponent<InteractionButton>();
}
private void Update() {
var isFacingCamera = (button.transform.forward * -1)
.IsFacing(button.transform.position,
Camera.main.transform.position, 120f);
button.controlEnabled = isFacingCamera;
}
}
}