コード例 #1
0
    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();
                }
            }
        }
    }
コード例 #2
0
 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);
     }
 }
コード例 #3
0
 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);
     }
 }