Пример #1
0
    void MouseRaycast()
    {
        // check hit
        RaycastHit hit;

        if (Physics.Raycast(m_Camera.ScreenPointToRay(Input.mousePosition), out hit))
        {
            // check mouse interactive item
            MouseInteractiveItem item = hit.transform.gameObject.GetComponent <MouseInteractiveItem> ();
            currentItem = item;

            // if current item exists, call Over
            if (currentItem && currentItem != lastItem)
            {
                currentItem.Over();
            }

            // if it's not the same as the last item, deactivate the last item
            if (currentItem != lastItem)
            {
                DeactivateLastItem();
            }

            lastItem = item;
        }
        else
        {
            // nothing was hit
            DeactivateLastItem();
            currentItem = null;
        }
    }
Пример #2
0
    void DeactivateLastItem()
    {
        if (lastItem == null)
        {
            return;
        }

        lastItem.Out();
        lastItem = null;
    }