示例#1
0
        void Start()
        {
            // check if view template contains DataContext component
            if (viewTemplate.GetComponent <IDataContext>() == null)
            {
                Debug.LogError("ViewTemplate need IDataContext component", gameObject);
                return;
            }

            // get dynamic controller
            dynamicController = GetComponent <IDynamicController>();
            if (dynamicController == null)
            {
                Debug.LogError("Need DynamicController component", gameObject);
                return;
            }

            if (usePool)
            {
                // get pool
                viewPool = ViewPoolManager.Instance.GetViewPool(viewTemplate);
            }
            else
            {
                // create local view pool
                viewPool = LocalViewPool.Create(transform);
            }

            CreateBinding();

            BindingUtility.AddBinding(bindingList, transform, out dataContext);
        }
示例#2
0
        void Start()
        {
            // get scroll rect
            scrollRect = GetComponent <ScrollRect>();
            if (scrollRect == null)
            {
                Debug.LogError("Require ScrollRect Component", gameObject);
                return;
            }

            // create containers
            nodeDictionary = new Dictionary <CanvasData.Node, NodeItem>();
            nodeItemList   = new List <NodeItem>();
            tempIndexList  = new List <int>();

            // create view pool
            var localViewPool = LocalViewPool.Create(transform);

            viewPool = new DelayedViewPool(localViewPool);

            // create object pool
            nodeItemPool = new ObjectPool <NodeItem>(() => new NodeItem(), x => x.Reset());

            InitContent();

            UpdateView();

            // add listener
            scrollRect.onValueChanged.AddListener(OnScrollRectChanged);
        }