Exemplo n.º 1
0
    public static List <txUIObject> raycast(Ray ray, SortedDictionary <int, List <txUIObject> > buttonList, int maxCount = 0)
    {
        bool cast = true;
        List <txUIObject> retList = new List <txUIObject>();
        RaycastHit        hit     = new RaycastHit();

        foreach (var box in buttonList)
        {
            int count = box.Value.Count;
            for (int i = 0; i < count; ++i)
            {
                txUIObject window = box.Value[i];
                if (window.getHandleInput() && window.Raycast(ray, out hit, 10000.0f))
                {
                    retList.Add(window);
                    // 如果射线不能穿透当前按钮,或者已经达到最大数量,则不再继续
                    if (!window.getPassRay() || maxCount > 0 && retList.Count >= maxCount)
                    {
                        cast = false;
                        break;
                    }
                }
            }
            if (!cast)
            {
                break;
            }
        }
        return(retList);
    }