Generating and Displaying Zones
This commit is contained in:
parent
2236ecd129
commit
f756c5fe6a
67 changed files with 1343 additions and 826 deletions
25
Assets/Scripts/UI/ClickRaycaster.cs
Normal file
25
Assets/Scripts/UI/ClickRaycaster.cs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ClickRaycaster : MonoBehaviour
|
||||
{
|
||||
public Camera RayCamera;
|
||||
private ClickCatcher _clickCatcher;
|
||||
|
||||
void Start()
|
||||
{
|
||||
_clickCatcher = GetComponent<ClickCatcher>();
|
||||
_clickCatcher.OnClick += pointer =>
|
||||
{
|
||||
RaycastHit hit;
|
||||
Physics.Raycast(RayCamera.ScreenPointToRay(pointer.position), out hit);
|
||||
if (hit.collider != null)
|
||||
{
|
||||
var clickable = hit.collider.GetComponent<ClickableCollider>();
|
||||
if (clickable != null)
|
||||
clickable.Click(pointer);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue