Exemplo n.º 1
0
 private void WolfToggle2_OnValueChanged(bool value)
 {
     if (value)
     {
         wolfSelector1.Deselect();
         wolfSelector2.Select();
     }
     else
     {
         wolfSelector2.Deselect();
     }
 }
Exemplo n.º 2
0
    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;
             * }
             */
        }
    }