| | 1 | | using DCL.Interface; |
| | 2 | | using DCL.Helpers; |
| | 3 | | using DCL.Models; |
| | 4 | | using DCLPlugins.UUIDEventComponentsPlugin.UUIDComponent.Interfaces; |
| | 5 | | using Ray = UnityEngine.Ray; |
| | 6 | |
|
| | 7 | | namespace DCL.Components |
| | 8 | | { |
| | 9 | | public class OnPointerDown : OnPointerEvent |
| | 10 | | { |
| | 11 | | public const string NAME = "pointerDown"; |
| | 12 | |
|
| | 13 | | public override void Report(WebInterface.ACTION_BUTTON buttonId, Ray ray, HitInfo hit) |
| | 14 | | { |
| 4 | 15 | | if (!enabled || !IsVisible()) |
| 0 | 16 | | return; |
| | 17 | |
|
| 4 | 18 | | Model model = this.model as OnPointerEvent.Model; |
| | 19 | |
|
| 4 | 20 | | if (ShouldReportEvent(buttonId, hit)) |
| | 21 | | { |
| 4 | 22 | | string meshName = pointerEventHandler.GetMeshName(hit.collider); |
| 4 | 23 | | string entityId = Environment.i.world.sceneController.entityIdHelper.GetOriginalId(entity.entityId); |
| 4 | 24 | | DCL.Interface.WebInterface.ReportOnPointerDownEvent(buttonId, scene.sceneData.id, model.uuid, |
| | 25 | | entityId, meshName, ray, hit.point, hit.normal, hit.distance); |
| | 26 | | } |
| 4 | 27 | | } |
| | 28 | |
|
| | 29 | | public bool ShouldReportEvent(WebInterface.ACTION_BUTTON buttonId, HitInfo hit) |
| | 30 | | { |
| 4 | 31 | | Model model = this.model as Model; |
| | 32 | |
|
| 4 | 33 | | return IsVisible() && |
| | 34 | | IsAtHoverDistance(hit.distance) && |
| | 35 | | (model.button == "ANY" || buttonId.ToString() == model.button); |
| | 36 | | } |
| | 37 | |
|
| | 38 | | public override int GetClassId() |
| | 39 | | { |
| 1 | 40 | | return (int) CLASS_ID_COMPONENT.UUID_ON_DOWN; |
| | 41 | | } |
| | 42 | |
|
| | 43 | | public override PointerInputEventType GetEventType() |
| | 44 | | { |
| 3346 | 45 | | return PointerInputEventType.DOWN; |
| | 46 | | } |
| | 47 | | } |
| | 48 | | } |