34 lines
800 B
C#
34 lines
800 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
|
|
public class Finger : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler{
|
|
|
|
[SerializeField, Range(1, 5)] int fingerIndex = 1;
|
|
bool selected;
|
|
|
|
HandManager hand;
|
|
|
|
void Awake(){
|
|
hand = GetComponentInParent<HandManager>();
|
|
}
|
|
|
|
public void OnPointerEnter(PointerEventData eventData){
|
|
selected = true;
|
|
}
|
|
|
|
public void OnPointerExit(PointerEventData eventData){
|
|
selected = false;
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update(){
|
|
if (selected){
|
|
if (Input.GetMouseButtonDown(0)){
|
|
hand.Cut(fingerIndex);
|
|
//gameObject.SetActive(false);
|
|
}
|
|
}
|
|
}
|
|
}
|