void SelectWolf() { // raycast from mouse position in camera Ray rayClick = cam.ScreenPointToRay(Input.mousePosition); RaycastHit raycastHit; if (Physics.Raycast(rayClick, out raycastHit, Mathf.Infinity, selectionLayer.value)) { Debug.DrawRay(rayClick.origin, rayClick.direction * 100, Color.red); WolfSelector wolfSelector = raycastHit.transform.GetComponentInChildren <WolfSelector>(); if (wolfSelector == null) { Debug.Log("[PointerController] SheepSelector not found in " + raycastHit.transform.name); } else { if (currentSelectedWolf != wolfSelector) { Debug.Log("[PointerController] Sheep selected: " + raycastHit.transform.name); if (currentSelectedWolf != null) { currentSelectedWolf.Deselect(); } currentSelectedWolf = wolfSelector; currentSelectedWolf.Select(); } else { Debug.Log("[PointerController] Same sheep selected: " + raycastHit.transform.name); } } } else { /* * Debug.DrawRay(rayClick.origin, rayClick.direction * 100, Color.yellow); * * Debug.Log("[PointerController] No sheep selected"); * * if(currentSelectedWolf != null) * { * currentSelectedWolf.Deselect(); * currentSelectedWolf = null; * } */ } }
private void OnWolfDeselected(WolfSelector w) { if (w == wolfSelector1) { wolfToggle1.SetIsOnWithoutNotify(false); wolfToggle1.interactable = true; } if (w == wolfSelector2) { wolfToggle2.SetIsOnWithoutNotify(false); wolfToggle2.interactable = true; } }
void Wolf_OnDeselection(WolfSelector w) { currentSelectedWolf = null; }
void Wolf_OnSelection(WolfSelector w) { currentSelectedWolf = w; }
void WolfSelector_OnDeselection(WolfSelector s) { Debug.Log("[Wolf] OnDeselection: " + name); isSelected = false; OnDeselect?.Invoke(); }
void Wolf_OnDeselection(WolfSelector s) { }
void Wolf_OnSelection(WolfSelector s) { currentWolf = s.gameObject; }