예제 #1
0
        public List <EAssetFileInfo> _depAssetFiles = new List <EAssetFileInfo>();      // 包含的资源名称

        #endregion

        #region 构造

        public EAssetBundleFileInfo(string tmpAbName)
        {
            AbName           = tmpAbName;
            FilePath         = EAssetBundleConst.AssetbundleDirectory + "/" + AbName;//Path.Combine(, ab_name);
            FileAbMemorySize = EPathHelper.GetFileSize(FilePath);
            _allDepends.Clear();
            _beDepends.Clear();
            _depAssetFiles.Clear();
        }
예제 #2
0
        public static TextureFormatInfo Create(string assetPath)
        {
            TextureFormatInfo info     = GetInfo(assetPath);
            TextureImporter   importer = AssetImporter.GetAtPath(assetPath) as TextureImporter;

            Debug.Assert(!(importer == null), "错误的地址:" + assetPath);
            if (importer == null)
            {
                return(null);
            }

            // 1.初始化纹理格式化信息
            info.Path            = importer.assetPath;
            info.ImportType      = importer.textureType;
            info.ImportShape     = importer.textureShape;
            info.ReadWriteEnable = importer.isReadable;
            info.MipmapEnable    = importer.mipmapEnabled;
            info.IsSpriteTag     = !string.IsNullOrEmpty(importer.spritePackingTag);
            info.AndroidFormat   = GetPlatformTextureSettings(importer, AssetFormatConst.PLATFORM_ANDROID);
            info.IosFormat       = GetPlatformTextureSettings(importer, AssetFormatConst.PLATFORM_IOS);

            // 计算纹理的大小内存占用
            Texture texture = AssetDatabase.LoadAssetAtPath <Texture>(assetPath);

            info.Width       = texture.width;
            info.Height      = texture.height;
            info.AndroidSize = EMemorySizeHelper.CalculateTextureSizeBytes(texture, info.AndroidFormat);
            info.IosSize     = EMemorySizeHelper.CalculateTextureSizeBytes(texture, info.IosFormat);
            info.MemSize     = (int)(Mathf.Max(info.AndroidSize, info.IosSize));
            info.FileSize    = EPathHelper.GetFileSize(assetPath);
            if (Selection.activeObject != texture)
            {
                Resources.UnloadAsset(texture);
            }

            if (++LoadCount % 256 == 0)
            {
                Resources.UnloadUnusedAssets();
            }

            return(info);
        }