コード例 #1
0
    protected override void OnStart()
    {
        // vertical

        var multiObjectPool = m_ScrollRect_Vertical.GetObjectPool <UIMultiObjectPool>();

        multiObjectPool.WarmPool(m_PushSize / 2, m_Signs[0]);   // 对象池预加载,可选
        multiObjectPool.WarmPool(m_PushSize / 2, m_Signs[1]);   // 对象池预加载,可选

        multiObjectPool.OnSignGetter = (index) =>
        {
            return(m_Signs[index % 2]);
        };

        m_ScrollRect_Vertical.RegisterParentView(this);         // 注册 Parent View,可选

        m_ScrollRect_Vertical.ListenLoadingStart(() =>          // 如果勾选了 Auto Loading ,则需要监听这个事件
        {
            StartCoroutine(LoadDataCoroutine());
        });

        // horizontal

        var simpleObjectPool_Horizontal = m_ScrollRect_Horizontal.GetObjectPool <UISimpleObjectPool>();

        simpleObjectPool_Horizontal.WarmPool(m_PushSize * 2);   // 对象池预加载,可选

        // grid

        var simpleObjectPool_Grid = m_ScrollRect_Grid.GetObjectPool <UISimpleObjectPool>();

        simpleObjectPool_Grid.WarmPool(m_PushSize * 2);         // 对象池预加载,可选
    }