init
This commit is contained in:
commit
fca6784fe7
571 changed files with 84105 additions and 0 deletions
84
Assets/Scripts/Hand/FakeFingerManager.cs
Normal file
84
Assets/Scripts/Hand/FakeFingerManager.cs
Normal file
|
@ -0,0 +1,84 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
public class FakeFingerManager : MonoBehaviour, IPointerDownHandler, IBeginDragHandler, IEndDragHandler, IDragHandler, IDropHandler{
|
||||
|
||||
public HandManager.FingerTypes fingerType = HandManager.FingerTypes.Default;
|
||||
|
||||
[SerializeField] Canvas canvas = default;
|
||||
|
||||
RectTransform rectTransform;
|
||||
CanvasGroup canvasGroup;
|
||||
Vector2 defaultPos;
|
||||
|
||||
[SerializeField] float smoothTime = .5f;
|
||||
[HideInInspector] public bool dragging;
|
||||
[HideInInspector] public Vector2 posToGo;
|
||||
Vector2 position;
|
||||
|
||||
[HideInInspector] public bool setPos;
|
||||
[HideInInspector] public int index;
|
||||
|
||||
void Awake(){
|
||||
rectTransform = GetComponent<RectTransform>();
|
||||
canvasGroup = GetComponent<CanvasGroup>();
|
||||
defaultPos = posToGo = rectTransform.anchoredPosition;
|
||||
}
|
||||
|
||||
public void OnBeginDrag(PointerEventData eventData){
|
||||
canvasGroup.blocksRaycasts = false;
|
||||
canvasGroup.alpha = .6f;
|
||||
dragging = true;
|
||||
setPos = false;
|
||||
}
|
||||
|
||||
public void OnDrag(PointerEventData eventData){
|
||||
rectTransform.anchoredPosition += eventData.delta / canvas.scaleFactor;
|
||||
}
|
||||
|
||||
public void OnEndDrag(PointerEventData eventData){
|
||||
StartCoroutine(ResetToDefaultPos());
|
||||
canvasGroup.blocksRaycasts = true;
|
||||
canvasGroup.alpha = 1f;
|
||||
}
|
||||
|
||||
public void OnPointerDown(PointerEventData eventData){
|
||||
|
||||
}
|
||||
|
||||
public void OnDrop(PointerEventData eventData){
|
||||
|
||||
}
|
||||
|
||||
void Update(){
|
||||
if(!dragging)
|
||||
rectTransform.anchoredPosition = Vector2.SmoothDamp(rectTransform.anchoredPosition, posToGo, ref position, smoothTime);
|
||||
}
|
||||
|
||||
IEnumerator ResetToDefaultPos(){
|
||||
yield return new WaitForSeconds(.1f);
|
||||
if (!setPos){
|
||||
/*switch(index){
|
||||
case 1:
|
||||
hand.finger1 = false;
|
||||
break;
|
||||
case 2:
|
||||
hand.finger2 = false;
|
||||
break;
|
||||
case 3:
|
||||
hand.finger3 = false;
|
||||
break;
|
||||
case 4:
|
||||
hand.finger4 = false;
|
||||
break;
|
||||
case 5:
|
||||
hand.finger5 = false;
|
||||
break;
|
||||
}*/
|
||||
posToGo = defaultPos;
|
||||
dragging = false;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue