-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathScrewSnapZone.cs
33 lines (27 loc) · 1.09 KB
/
ScrewSnapZone.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright (c) Meta Platforms, Inc. and affiliates.
using UnityEngine;
using UnityEngine.Events;
namespace CrypticCabinet.Interactions
{
/// <summary>
/// Defines a snap zone onto which a screwable object can snap via a screwing-in motion.
/// </summary>
[RequireComponent(typeof(Rigidbody))]
public class ScrewSnapZone : MonoBehaviour
{
public Vector3 GuideBottomPosition => transform.position;
public Vector3 GuideTopPosition => GuideBottomPosition + transform.up * ScrewHeight;
public float ScrewHeight = 0.1f;
public bool HasObject => CurrentObject;
[HideInInspector] public ScrewableObject CurrentObject;
public UnityEvent<ScrewableObject> OnObjectSnap;
public UnityEvent<ScrewableObject> OnObjectCompleteScrew;
public UnityEvent<ScrewableObject> OnObjectStartUnscrew;
public UnityEvent<ScrewableObject> OnObjectRemoved;
private void OnDrawGizmosSelected()
{
Gizmos.color = Color.blue;
Gizmos.DrawLine(GuideBottomPosition, GuideTopPosition);
}
}
}