예제 #1
0
    //////////////////////////////////////////////////////////////////////////

    public bool SelectItem(UAP_BaseElement element, bool forceRepeatItem = false)
    {
        for (int i = 0; i < m_AllElements.Count; ++i)
        {
            Accessible_UIElement accessElement = m_AllElements[i];
            if (accessElement.m_Object == element)
            {
                m_CurrentItemIndex = i;
                // Notify the Manager that this should be the active container
                return(UAP_AccessibilityManager.MakeActiveContainer(this, forceRepeatItem));
            }
        }
        return(false);
    }
예제 #2
0
    //////////////////////////////////////////////////////////////////////////

    void Register_Item(UAP_BaseElement item)
    {
        EUIElement type = item.m_Type;

        // Is this the correct container for this element?
        AccessibleUIGroupRoot container = null;
        Transform             tr        = item.transform;

        container = tr.gameObject.GetComponent <AccessibleUIGroupRoot>();
        while (container == null && tr.parent != null)
        {
            tr        = tr.parent;
            container = tr.gameObject.GetComponent <AccessibleUIGroupRoot>();
        }
        if (container != this)
        {
            return;
        }

        // sanity check
        if (container == null)
        {
            Debug.LogError("[Accessibility] A UI element tried to register with " + gameObject.name + " but not only am I not the right container, there seems to be no container in it's parent hierarchy.");
            return;
        }

        // sorted by position, top to bottom, left to right
        // sort it into the list of UI items
        Accessible_UIElement newElement = new Accessible_UIElement(item, type, m_AllElements.Count);
        int  order          = newElement.m_PositionOrder;
        int  secondaryOrder = newElement.m_SecondaryOrder;
        int  count          = m_AllElements.Count;
        bool added          = false;

        for (int i = 0; i < count; ++i)
        {
            if (order < m_AllElements[i].m_PositionOrder)
            {
                m_AllElements.Insert(i, newElement);
                added = true;
                break;
            }
            else if (order == m_AllElements[i].m_PositionOrder)
            {
                // Take Secondary Order into account (for scroll views an the like)
                int difference = m_AllElements[i].m_SecondaryOrder - secondaryOrder;
                //int testVal = m_AllElements[i].m_SecondaryOrder;
                //int currentVal = secondaryOrder;
                if (difference > 0)
                {
                    m_AllElements.Insert(i, newElement);
                    added = true;
                    break;
                }
            }
        }
        if (!added)
        {
            m_AllElements.Add(newElement);
        }

        // Save it if this element is to be the first one to use
        if (item.m_ForceStartHere)
        {
            m_CurrentStartItem = item;
        }
    }