public virtual void Update()
{
if (renderer.isVisible && Input.GetMouseButton(0))
{
if(!selectedByClick)
{
Vector3 camPos = Camera.mainCamera.WorldToScreenPoint(transform.position);
camPos.y = BoxSelection.InvertMouseY(camPos.y);
selected = BoxSelection.selection.Contains(camPos);
}
if (selected)
{
//must change state
foreach(Transform child in transform)
{
if(child.name == "Sphere")
child.renderer.enabled = true;
}
}
else //must change state
{
foreach(Transform child in transform)
{
if(child.name == "Sphere")
child.renderer.enabled = false;
}
}
}
if (selected && Input.GetMouseButtonUp(1))
{
//Récupérer la position du clic droit
//Vector3 dest = BoxSelection.getDestination();
RaycastHit hit;
Ray r = Camera.mainCamera.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(r, out hit))
{
Vector3 dest = hit.point;
Debug.Log("destination : " + dest);
Vector3 newPosition = dest;
newPosition.y = 1;
Instantiate(mouseSpriteMove, newPosition, Quaternion.identity);
if (dest != Vector3.zero)
{
moveToDestination = dest;
moveToDestination.y += floorOffset;
}
//transmettre la position du clic à l'unit
destination = dest;
}
}
computeUnityScale();
}