Пример #1
0
 public bool SameAs(IMySelectable other)
 {
     if (this == other)
     {
         return(same);
     }
     return(false);
 }
Пример #2
0
 public void OnPointerClick(PointerEventData eventData)
 {
     if (isSpawnOn)
     {
         if (targetCanSpawn)
         {
             DoSpawn(eventData);
         }
     }
     else
     {
         Selected = null;
     }
 }
Пример #3
0
    IMySelectable DeselectOld()
    {
        //deselect older selection
        IMySelectable oldSel = null;

        if (selected != null)
        {
            oldSel = selected.GetComponent <IMySelectable>();
            if (oldSel != null)
            {
                oldSel.SetSelected(false);
            }
        }

        return(oldSel);
    }
Пример #4
0
 public bool SameAs(IMySelectable other)
 {
     return(this == other);
 }
Пример #5
0
    void handleClicked(Vector3 CursorScreenPosition)
    {
        Debug.Log("clicked");

        IMySelectable oldSel = DeselectOld();


        RaycastHit hit;
        //Ray r = cam.ScreenPointToRay(Input.mousePosition);
        Ray r = cam.ScreenPointToRay(CursorScreenPosition);

        if (Physics.Raycast(r, out hit, Mathf.Infinity, layerMask))
        {
            GameObject go = hit.collider.gameObject;
            Debug.LogFormat("GameObject hit: {0}", go.name);
            IMySelectable sel = go.GetComponent <IMySelectable>();



            if (sel == null)
            {
                sel = go.GetComponentInParent <IMySelectable>();
                if (sel != null)
                {
                    go = go.transform.parent.gameObject;
                }
                else
                {
                    go = clickedPlane();
                    if (go == null)
                    {
                        selected = null;
                        return;
                    }
                    sel = go.GetComponent <IMySelectable>();
                }
            }



            if (sel.SameAs(oldSel))
            {
                selected = null;
                return;
            }

            if (sel != null)
            {
                selected = go;
                sel.SetSelected(true);
            }
        }
        else
        {
            Debug.Log("no GameObject hit");
            if (clickedPlane() == null)
            {
                selected = null;
                return;
            }
        }
    }