Exemplo n.º 1
0
    // 自动检查卸载点资源包
    // UI 资源暂时不卸载
    // 已经加载但是还有缓存资源没有加载点不进行卸载
    // 正在加载点资源也不进行卸载
    private static void CheckUnloadPackage()
    {
        List <string> unloadPackageList = new List <string>();

        using (var i = _packageCacheDic.GetEnumerator())
        {
            RGPackage package = null;
            while (i.MoveNext())
            {
                package = i.Current.Value;
                if (package != null)
                {
                    if (package.IsLoadPackage)
                    {
                        if (!package.IsCacheNeedLoad)
                        {
                            if (!package.IsUI && package.IsAutoRelease && !package.IsForverBundle)
                            {
                                RGLog.DebugResLoad("<color=red> Auto Unload bundle</color> -> {0}", package.PackageName);
                                package.UnloadAll();;
                                unloadPackageList.Add(package.PackageName);
                            }
                        }
                    }
                }
            }
        }
        for (int i = 0; i < unloadPackageList.Count; i++)
        {
            _packageCacheDic.Remove(unloadPackageList[i]);
        }
    }
Exemplo n.º 2
0
    // 获得包
    public static RGPackage GetPackage(string packageName)
    {
        RGPackage package = null;

        if (_packageCacheDic.TryGetValue(packageName, out package))
        {
            return(package);
        }
        return(null);
    }
Exemplo n.º 3
0
    //创建包
    public static RGPackage CreatePackage(string packageName)
    {
        var package = GetPackage(packageName);

        if (package == null)
        {
            package = RGPackage.Create(packageName);
            _packageCacheDic.Add(packageName, package);
        }
        return(package);
    }
Exemplo n.º 4
0
    public static RGPackage CreatePackage(string packageName)
    {
        RGLog.Debug(" CreatePackage --> " + packageName);
        var package = GetPackage(packageName);

        if (package == null)
        {
            package = RGPackage.Create(packageName);
            _packageCacheDic.Add(packageName, package);
        }
        return(package);
    }
Exemplo n.º 5
0
 // 卸载全部包
 public static void UnloadAll()
 {
     using (var i = _packageCacheDic.GetEnumerator())
     {
         RGPackage package = null;
         while (i.MoveNext())
         {
             package = i.Current.Value;
             if (package != null)
             {
                 package.UnloadAll();
             }
         }
     }
     _packageCacheDic.Clear();
 }
Exemplo n.º 6
0
    public static RGPackage Create(string packageName)
    {
        var rg = new RGPackage(packageName);

        return(rg);
    }