/// <summary>
 /// Queues a texture for eventual loading.
 /// </summary>
 /// <param name="pcc">The full path of the pcc where the texture export is.</param>
 public PreviewTextureEntry LoadTexture(string pcc, int exportid)
 {
     foreach (PreviewTextureEntry e in cache)
     {
         if (e.PCCPath == pcc && e.ExportID == exportid)
         {
             return(e);
         }
     }
     using (ME3Package texpcc = MEPackageHandler.OpenME3Package(pcc))
     {
         PreviewTextureEntry      entry = new PreviewTextureEntry(pcc, exportid);
         Unreal.Classes.Texture2D metex = new Unreal.Classes.Texture2D(texpcc, exportid);
         Texture2DDescription     desc  = new Texture2DDescription();
         try
         {
             entry.Texture     = metex.generatePreviewTexture(Device, out desc);
             entry.TextureView = new ShaderResourceView(Device, entry.Texture);
             cache.Add(entry);
             return(entry);
         } catch
         {
             return(null);
         }
     }
 }
        /// <summary>
        /// Queues a texture for eventual loading.
        /// </summary>
        /// <param name="pcc">The full path of the pcc where the texture export is.</param>
        /// <param name="exportid"></param>
        //public PreviewTextureEntry LoadTexture(string pcc, int exportid)
        //{
        //    foreach (PreviewTextureEntry e in cache)
        //    {
        //        if (e.PCCPath == pcc && e.ExportID == exportid)
        //        {
        //            return e;
        //        }
        //    }
        //    using (var texpcc = MEPackageHandler.OpenMEPackage(pcc))
        //    {
        //        PreviewTextureEntry entry = new PreviewTextureEntry(pcc, exportid);
        //        Unreal.Classes.Texture2D metex = new Unreal.Classes.Texture2D(texpcc.getUExport(exportid));
        //        try
        //        {
        //            entry.Texture = metex.generatePreviewTexture(Device, out Texture2DDescription _);
        //            entry.TextureView = new ShaderResourceView(Device, entry.Texture);
        //            cache.Add(entry);
        //            return entry;
        //        } catch
        //        {
        //            return null;
        //        }
        //    }
        //}

        /// <summary>
        /// Queues a texture for eventual loading.
        /// </summary>
        /// <param name="pcc">The full path of the pcc where the texture export is.</param>
        /// <param name="exportid"></param>
        public PreviewTextureEntry LoadTexture(ExportEntry export, Texture2DMipInfo preloadedMipInfo = null, byte[] decompressedTextureData = null)
        {
            foreach (PreviewTextureEntry e in cache)
            {
                if (e.TextureExport.FileRef.FilePath == export.FileRef.FilePath && e.TextureExport.UIndex == export.UIndex)
                {
                    return(e);
                }
            }
            //using (var texpcc = MEPackageHandler.OpenMEPackage(pcc))
            //{
            PreviewTextureEntry entry = new PreviewTextureEntry(export);

            ME3ExplorerCore.Unreal.Classes.Texture2D metex = new ME3ExplorerCore.Unreal.Classes.Texture2D(export);
            try
            {
                if (preloadedMipInfo != null && metex.Export != preloadedMipInfo.Export)
                {
                    throw new Exception();
                }
                entry.Texture     = metex.generatePreviewTexture(Device, out Texture2DDescription _, preloadedMipInfo, decompressedTextureData);
                entry.TextureView = new ShaderResourceView(Device, entry.Texture);
                cache.Add(entry);
                return(entry);
            }
            catch
            {
                return(null);
            }
            //}
        }