2020-12-22 03:13:43 +00:00
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
|
|
|
|
using System;
|
2020-03-29 04:19:24 +01:00
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
using UnityEngine.EventSystems;
|
|
|
|
|
|
|
|
|
|
|
|
public class ClickableCollider : MonoBehaviour
|
|
|
|
|
|
{
|
2022-08-08 22:43:55 +01:00
|
|
|
|
public event Action<ClickableCollider, PointerEventData, Ray, RaycastHit> OnClick;
|
2020-03-29 04:19:24 +01:00
|
|
|
|
|
2022-08-08 22:43:55 +01:00
|
|
|
|
public void Click(PointerEventData eventData, Ray ray, RaycastHit raycastHit) => OnClick?.Invoke(this, eventData, ray, raycastHit);
|
2020-04-23 03:31:17 +01:00
|
|
|
|
|
2020-04-29 11:27:55 +01:00
|
|
|
|
public void Clear()
|
|
|
|
|
|
{
|
|
|
|
|
|
OnClick = null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-04-23 03:31:17 +01:00
|
|
|
|
void Start()
|
|
|
|
|
|
{
|
|
|
|
|
|
var proto = GetComponent<Prototype>();
|
|
|
|
|
|
if(proto != null)
|
|
|
|
|
|
proto.OnReturnToPool += () => OnClick = null;
|
|
|
|
|
|
}
|
2020-03-29 04:19:24 +01:00
|
|
|
|
}
|