コード例 #1
0
        /// <summary>
        /// Add index of the image to queue list
        /// </summary>
        /// <param name="index">Current index of image list</param>
        private void UpdateQueueList(int index)
        {
            // check valid index
            if (index < 0 || index >= ImgList.Count)
            {
                return;
            }

            var list = new HashSet <int>
            {
                index
            };

            var maxCachedItems = (MaxQueue * 2) + 1;
            var iRight         = index;
            var iLeft          = index;

            // add index in the range in order: index -> right -> left -> ...
            for (var i = 0; list.Count < maxCachedItems && list.Count < ImgList.Count; i++)
            {
                // if i is even number
                if ((i & 1) == 0)
                {
                    // add right item: [index + 1; ...; to]
                    iRight++;

                    if (iRight < ImgList.Count)
                    {
                        list.Add(iRight);
                    }
                    else
                    {
                        list.Add(iRight - ImgList.Count);
                    }
                }
                // if i is odd number
                else
                {
                    // add left item: [index - 1; ...; from]
                    iLeft--;

                    if (iLeft >= 0)
                    {
                        list.Add(iLeft);
                    }
                    else
                    {
                        list.Add(ImgList.Count + iLeft);
                    }
                }
            }

            // release the resources
            foreach (var indexItem in FreeList)
            {
                if (!list.Contains(indexItem) && indexItem >= 0 && indexItem < ImgList.Count)
                {
                    ImgList[indexItem].Dispose();
                }
            }

            // update new index of free list
            FreeList.Clear();
            FreeList.AddRange(list);

            // update queue list
            QueuedList.Clear();
            QueuedList.AddRange(list);
        }
コード例 #2
0
    public void WriteToBuffers(FreeList <Vector3> v, FreeList <Vector2> u, FreeList <Color> c, FreeList <Vector3> n, FreeList <Vector4> t, FreeList <Vector2> u2)
#endif
    {
        if (mRtpVerts != null && mRtpVerts.Count > 0)
        {
            if (n == null)
            {
#if NGUI_BACKUP
                for (int i = 0, imax = mRtpVerts.Count; i < imax; ++i)
                {
                    v.Add(mRtpVerts[i]);
                    u.Add(uvs[i]);
                    c.Add(cols[i]);
                }
#else
                v.AddRange(mRtpVerts);
                u.AddRange(uvs);
                c.AddRange(cols);
#endif
            }
            else
            {
#if NGUI_BACKUP
                for (int i = 0, imax = mRtpVerts.Count; i < imax; ++i)
                {
                    v.Add(mRtpVerts[i]);
                    u.Add(uvs[i]);
                    c.Add(cols[i]);
                    n.Add(mRtpNormal);
                    t.Add(mRtpTan);
                }
#else
                v.AddRange(mRtpVerts);
                u.AddRange(uvs);
                c.AddRange(cols);

                for (int i = 0, imax = mRtpVerts.Count; i < imax; ++i)
                {
                    n.Add(mRtpNormal);
                    t.Add(mRtpTan);
                }
#endif
            }

            if (u2 != null)
            {
#if NGUI_BACKUP
                Vector4 uv2 = Vector4.zero;
#else
                Vector2 uv2 = Vector2.zero;
#endif

                for (int i = 0, imax = verts.Count; i < imax; ++i)
                {
                    uv2.x = verts[i].x;
                    uv2.y = verts[i].y;
                    u2.Add(uv2);
                }
            }

            if (onCustomWrite != null)
            {
                onCustomWrite(v, u, c, n, t, u2);
            }
        }
    }