コード例 #1
0
        public bool TryAdd(Texture2D image, out Allocator2D.Alloc2D alloc, out RectInt rect)
        {
            if (disposed)
            {
                DisposeHelper.NotifyDisposedUsed(this);
                alloc = new Allocator2D.Alloc2D();
                rect  = new RectInt();
                return(false);
            }

            if (!m_Allocator.TryAllocate(image.width + m_2Padding, image.height + m_2Padding, out alloc))
            {
                rect = new RectInt();
                return(false);
            }

            m_CurrentSize.x = Mathf.Max(m_CurrentSize.x, UIRUtility.GetNextPow2(alloc.rect.xMax));
            m_CurrentSize.y = Mathf.Max(m_CurrentSize.y, UIRUtility.GetNextPow2(alloc.rect.yMax));
            rect            = new RectInt(alloc.rect.xMin + m_1Padding, alloc.rect.yMin + m_1Padding, image.width, image.height);

            Update(image, rect);

            return(true);
        }