Exemplo n.º 1
0
 public void BindToWorldObject(GameObject worldObject)
 {
     partner = worldObject.GetComponent <WorldClickable>();
     if (partner == null)
     {
         partner = worldObject.AddComponent <WorldClickable>();
     }
     partner.partner = this;
     renderTo        = partner.renderTo;
     UIMaster.i.RegisterWorldBoundIcon(this);
     OnBind();
 }
Exemplo n.º 2
0
    bool RaycastForWorldObjectClickables()
    {
        HashSet <WorldClickable> clickables = new HashSet <WorldClickable>();

        if (!EventSystem.current.IsPointerOverGameObject())
        {
            Ray screenRay = Camera.main.ScreenPointToRay(Input.mousePosition);

            foreach (int layer in worldClickableLayers)
            {
                RaycastHit hit;
                int        layerMask = 1 << layer;
                if (Physics.Raycast(screenRay, out hit, Mathf.Infinity, layerMask))
                {
                    WorldClickable clickable = hit.collider.GetComponent <WorldClickable>();
                    if (clickable != null)
                    {
                        if (Input.GetMouseButtonDown(0) && selectedUI != clickable.partner)
                        {
                            SelectUI(clickable.partner);
                        }
                        else
                        {
                            WorldHoverComponent(clickable.partner);
                        }
                        clickables.Add(clickable);
                    }
                }
            }
        }

        foreach (WorldBoundIcon icon in worldBoundIcons)
        {
            if (!clickables.Contains(icon.partner) && icon.WorldHovered && !icon.MouseOver)
            {
                WorldUnhoverComponent(icon);
            }
        }

        return(clickables.Count > 0);
    }