private void InteractableManagement() { if (Input.GetMouseButtonDown(0)) { if (eventSystem.IsPointerOverGameObject() == false) { Vector2 position = mainCamera.ScreenToWorldPoint(Input.mousePosition); RaycastHit2D hit = Physics2D.Raycast(position, Vector2.down, Mathf.Infinity); Interactable interactable = hit.transform?.GetComponent <Interactable>(); if (currentActiveInteractable.value != null && currentActiveInteractable.value is Unit) { currentSelectedUnit = currentActiveInteractable.value.GetComponent <AvatarAgentMove>(); currentSelectedUnit.MoveToDestination(position); } } } else if (Input.GetMouseButtonDown(1)) { if (currentActiveInteractable.value != null) { currentActiveInteractable.value.ToggleSelectionEffect(); currentActiveInteractable.value = null; currentSelectedUnit = null; } } }
private void Awake() { moveUnit = GetComponent <AvatarAgentMove>(); }