Пример #1
0
        private void OnClick(MouseClickDetector mouseButton)
        {
            if (mouseButton == leftMouseButton)
            {
                Vector3 mp       = Input.mousePosition;
                Ray     mouseRay = camera.ScreenPointToRay(mp);

                RaycastHit raycastHit;
                if (Physics.Raycast(mouseRay, out raycastHit))
                {
                    var tile = raycastHit.collider.gameObject.GetComponent <Tile>();

                    if (tile != null)
                    {
                        TileSelected.Invoke(tile);
                    }

                    var entity = raycastHit.collider.gameObject.GetComponent <Entity>();
                    if (entity != null)
                    {
                        EntitySelected.Invoke(entity);
                    }
                }
            }
        }
Пример #2
0
 private void Awake()
 {
     leftMouseButton = new MouseClickDetector(0);
     leftMouseButton.onButtonDown += OnClick;
 }