public override bool AllocateRect(int width, int height, out RectInt uvs) { if (disposed) { DisposeHelper.NotifyDisposedUsed(this); uvs = new RectInt(); return(false); } if (m_Allocator == null) { m_Allocator = new UIRAtlasAllocator(m_InitialSize, m_MaxSize, 0); } if (!m_Allocator.TryAllocate(width, height, out uvs)) { return(false); } uvs = new RectInt(uvs.x, uvs.y, width, height); // We don't want to call this every time SetTexel is called and we don't expect AllocateRect to be called // often, so we create/expand the texture immediately. For this reason, a sensible initial size should be // set to avoid copies during the initialization phase, where multiple allocs may occur. CreateOrExpandTexture(); return(true); }
protected override void Dispose(bool disposing) { if (!disposed && disposing) { UIRUtility.Destroy(m_Texture); m_Texture = null; m_Texels = new NativeArray <T>(); m_Allocator?.Dispose(); m_Allocator = null; } base.Dispose(disposing); }