Esempio n. 1
0
        //////////////////////////////////////////////////////////////////////////

        public Accessible_UIElement(UAP_BaseElement item, EUIElement type, int index)
        {
            m_Type   = type;
            m_Object = item;
            GameObject targetGO = item.GetTargetGameObject();

            // Is this item inside a scroll view?
            if (targetGO.GetComponentInParent <ScrollRect>() != null)
            {
                item.m_IsInsideScrollView = true;
            }
#if ACCESS_NGUI
            if (targetGO.GetComponentInParent <UIScrollView>() != null)
            {
                item.m_IsInsideScrollView = true;
            }
#endif

            CalculatePositionOrder(item, index);
            m_Object.m_PositionOrder  = m_PositionOrder;
            m_Object.m_SecondaryOrder = m_SecondaryOrder;
            m_Object.m_Pos            = m_Pos;
        }
Esempio n. 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;
        }
    }