void Update() { if (Input.GetMouseButtonDown(0)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit, 100)) { ClickSelectable selectable = hit.transform.gameObject.GetComponent <ClickSelectable>(); if (selectable != null) { selectable.leftClickSelect(); } } } else if (Input.GetMouseButtonDown(1)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit, 100)) { ClickSelectable selectable = hit.transform.gameObject.GetComponent <ClickSelectable>(); if (selectable != null) { selectable.rightClickSelect(); } } } }
public void DidSelect(ClickSelectable selectable) { if (manager == null) { print("MANAGER IS NULL"); return; } if (selectable == representation.GetComponent <ClickSelectable>()) { manager.FocusUnit(this); } else { GameObject selected = selectable.gameObject; manager.DidSelectUnitAndArrow(this, selected); } }
public void LeftSelect(ClickSelectable selectable) { if (manager == null) { print("MANAGER IS NULL"); return; } if (selectable == representation.GetComponent <ClickSelectable>()) { manager.DestroyUnit(gameObject); } else { GameObject selected = selectable.gameObject; manager.DestroyUnit(selected); } }