示例#1
0
    IPickable CheckPickable()
    {
        if (null != UICamera.hoveredObject)
        {
            return(null);
        }

        Ray ray = PeCamera.mouseRay;

        IPickable curPickable = null;
        EPriority curPriority = MousePicker.EPriority.Level0;
        float     maxDistance = GetMaxDistance(ray);
        float     curDistance = maxDistance;

        for (int i = 0; i < mPickableList.Count; i++)
        {
            IPickable pickable = mPickableList [i];
            if (null == pickable)
            {
                continue;
            }
            float dis = pickable.CheckPick(ray);
            if (dis > maxDistance)
            {
                continue;
            }
            if (pickable.priority > curPriority)
            {
                curPriority = pickable.priority;
                curDistance = dis;
                curPickable = pickable;
            }
            else if (pickable.priority == curPriority)
            {
                if (curDistance > dis)
                {
                    curDistance = dis;
                    curPickable = pickable;
                }
            }
        }
        return(curPickable);
    }