using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace BNG {
///
/// Shows a ring at the grab point of a grabbable if within a certain distance
///
public class RingHelper : MonoBehaviour {
[Tooltip("The Grabbable Object to Observe")]
public Grabbable grabbable;
[Tooltip("(Optional) If specified, the ring helper will only be valid if this Grabpoint is the nearest on the the grabbable object")]
public GrabPoint Grabpoint;
[Tooltip("Default Color of the ring")]
public Color RingColor = Color.white;
///
/// Color to use if selected by primary controller
///
[Tooltip("Color to use if selected by primary controller")]
public Color RingSelectedColor = Color.white;
///
/// Color to use if selected by secondary controller
///
[Tooltip("Color to use if selected by secondary controller")]
public Color RingSecondarySelectedColor = Color.white;
public float ringSizeInRange = 1500f;
public float ringSizeGrabbable = 1100f; // Lower pixel size the bigger the font
///
/// Don't show grab rings if left and right controllers / grabbers are holding something
///
[Tooltip("Don't show grab rings if left and right controllers / grabbers are holding something")]
public bool HideIfHandsAreFull = true;
///
/// How fast to lerp the opacity if being hidden / shown
///
[Tooltip("How fast to lerp the opacity if being hidden / shown")]
public float RingFadeSpeed = 5;
Canvas canvas;
Text text;
CanvasScaler scaler;
///
/// Used to determine if hands are full
///
Grabber leftGrabber;
Grabber rightGrabber;
Grabber closestGrabber;
bool handsFull = false;
// Animate opacity
private float _initalOpacity;
private float _currentOpacity;
Transform mainCam;
void Start() {
AssignCamera();
if (grabbable == null) {
grabbable = transform.parent.GetComponent();
}
canvas = GetComponent