コード例 #1
0
ファイル: AssetTarget.cs プロジェクト: 517752548/-
    public FastAssetTarget(Object o, FileInfo file, string assetPath)
    {
        this.asset           = o;
        this.file            = file;
        this.assetPath       = assetPath;
        this.bundleShortName = file.Name.ToLower();
        this.bundleName      = FastAssetBundleUtils.ConvertToABName(assetPath) + FastContent.BundleSuffix;
        this.bundleSavePath  = Path.Combine(FastAssetBundleUtils.pathResolver.BundleSavePath, bundleName);

        _isFileChanged = true;
    }
コード例 #2
0
ファイル: AssetTarget.cs プロジェクト: 517752548/-
 public string GetHash()
 {
     if (type == FastAssetType.Builtin)
     {
         return("0000000000");
     }
     else
     {
         return(FastAssetBundleUtils.GetFileHash(file.FullName));
     }
 }
コード例 #3
0
    public virtual void Analyze()
    {
        var all = FastAssetBundleUtils.GetAll();

        foreach (FastAssetTarget target in all)
        {
            target.Analyze();
        }
        all = FastAssetBundleUtils.GetAll();
        foreach (FastAssetTarget target in all)
        {
            target.Merge();
        }
        all = FastAssetBundleUtils.GetAll();
        foreach (FastAssetTarget target in all)
        {
            target.BeforeExport();
        }
    }
コード例 #4
0
ファイル: AssetBundleBuilder5x.cs プロジェクト: 517752548/-
    public override void Export()
    {
        base.Export();

        List <AssetBundleBuild> list = new List <AssetBundleBuild>();
        //标记所有 asset bundle name
        var all = FastAssetBundleUtils.GetAll();

        for (int i = 0; i < all.Count; i++)
        {
            FastAssetTarget target = all[i];
            if (target.needSelfExport)
            {
                AssetBundleBuild build = new AssetBundleBuild();
                build.assetBundleName = target.bundleName;
                build.assetNames      = new string[] { target.assetPath };
                list.Add(build);
            }
        }

        //开始打包
        BuildPipeline.BuildAssetBundles(pathResolver.BundleSavePath, list.ToArray(), BuildAssetBundleOptions.ChunkBasedCompression, EditorUserBuildSettings.activeBuildTarget);

        AssetBundle ab = AssetBundle.LoadFromFile(pathResolver.BundleSavePath + pathResolver.BundleName);

        AssetBundleManifest manifest = ab.LoadAsset("AssetBundleManifest") as AssetBundleManifest;

        //hash
        for (int i = 0; i < all.Count; i++)
        {
            FastAssetTarget target = all[i];
            if (target.needSelfExport)
            {
                Hash128 hash = manifest.GetAssetBundleHash(target.bundleName);
                target.bundleCrc = hash.ToString();
            }
        }
        ab.Unload(true);
        this.RemoveUnused(all);

        AssetDatabase.RemoveUnusedAssetBundleNames();
        AssetDatabase.Refresh();
    }
コード例 #5
0
 public void AddRootTargets(DirectoryInfo bundleDir, string[] partterns = null, SearchOption searchOption = SearchOption.AllDirectories)
 {
     if (partterns == null)
     {
         partterns = new string[] { "*.*" }
     }
     ;
     for (int i = 0; i < partterns.Length; i++)
     {
         FileInfo[] prefabs = bundleDir.GetFiles(partterns[i], searchOption);
         foreach (FileInfo file in prefabs)
         {
             if (file.Extension.Contains("meta"))
             {
                 continue;
             }
             FastAssetTarget target = FastAssetBundleUtils.Load(file);
             target.exportType = FastAssetBundleExportType.Root;
         }
     }
 }
コード例 #6
0
 public void End()
 {
     FastAssetBundleUtils.ClearCache();
     EditorUtility.ClearProgressBar();
 }
コード例 #7
0
 public void Begin()
 {
     EditorUtility.DisplayProgressBar("Loading", "Loading...", 0.1f);
     FastAssetBundleUtils.Init();
 }
コード例 #8
0
ファイル: AssetTarget.cs プロジェクト: 517752548/-
    /// <summary>
    /// 分析引用关系
    /// </summary>
    public void Analyze()
    {
        if (_isAnalyzed)
        {
            return;
        }
        _isAnalyzed = true;

        _cacheInfo     = FastAssetBundleUtils.GetCacheInfo(assetPath);
        _isFileChanged = _cacheInfo == null || !_cacheInfo.fileHash.Equals(GetHash());
        if (_cacheInfo != null)
        {
            _bundleCrc = _cacheInfo.bundleCrc;
            if (_isFileChanged)
            {
                Debug.Log("File was changed : " + assetPath);
            }
        }

        Object[]      deps    = EditorUtility.CollectDependencies(new Object[] { asset });
        List <Object> depList = new List <Object>();

        for (int i = 0; i < deps.Length; i++)
        {
            Object o = deps[i];
            //不包含脚本对象
            //不包含LightingDataAsset对象
            if (o is MonoScript || o is LightingDataAsset)
            {
                continue;
            }

            //不包含builtin对象
            string path = AssetDatabase.GetAssetPath(o);
            if (path.StartsWith("Resources"))
            {
                continue;
            }

            depList.Add(o);
        }
        deps = depList.ToArray();


        var res = from s in deps
                  let obj = AssetDatabase.GetAssetPath(s)
                            select obj;
        var paths = res.Distinct().ToArray();

        for (int i = 0; i < paths.Length; i++)
        {
            if (File.Exists(paths[i]) == false)
            {
                //Debug.Log("invalid:" + paths[i]);
                continue;
            }
            FileInfo        fi     = new FileInfo(paths[i]);
            FastAssetTarget target = FastAssetBundleUtils.Load(fi);
            if (target == null)
            {
                continue;
            }

            this.AddDependParent(target);

            target.Analyze();
        }
    }