Exemplo n.º 1
0
        public override void UnloadUnusedAssets()
        {
            List <int> assetsNotAlive = new List <int>();

            foreach (var item in m_Cache)
            {
                CResource res = item.Value;
                LogUtility.Log("[CResources.UnloadUnusedAssets]{0}  {1}", item.Value.Location.InternalId, item.Value.IsAlive);
                if (res.IsAlive == false)
                {
                    IResourceLocation location = res.Location;
                    if (location.HasDependencies)
                    {
                        for (int i = 0; i < location.Dependencies.Count; i++)
                        {
                            CResources.Release <object>(location.Dependencies[i], null);
                        }
                    }
                    assetsNotAlive.Add(item.Key);
                }
            }
            for (int i = 0; i < assetsNotAlive.Count; i++)
            {
                m_Cache.Remove(assetsNotAlive[i]);
            }
        }
Exemplo n.º 2
0
 public override TObject Provide <TObject>(IResourceLocation location)
 {
     if (location.HasDependencies)
     {
         IResourceLocation bundleLocation = location.Dependencies[0];
         AssetBundle       bundle         = CResources.Load <AssetBundle>(bundleLocation);
         LogUtility.Log("Load asset from bundle " + location.InternalId);
         return(bundle.LoadAsset(Path.GetFileName(location.InternalId), typeof(TObject)) as TObject);
     }
     else
     {
         throw new CResourcesException(" Can not find bundle Location " + location.InternalId);
     }
 }
Exemplo n.º 3
0
        public override TObject Provide <TObject>(IResourceLocation location)
        {
            if (location.HasDependencies)
            {
                for (int i = 0; i < location.Dependencies.Count; i++)
                {
                    CResources.Load <AssetBundle>(location.Dependencies[i]);
                }
            }
            LogUtility.Log("[Load bundle] " + location.InternalId);
            AssetBundle bundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Application.dataPath), "assetbundles/cresources/" + location.InternalId));

            return(bundle as TObject);
        }
Exemplo n.º 4
0
        public override CResource ProvideAsync <TObject>(IResourceLocation location)
        {
            if (location.HasDependencies)
            {
                for (int i = 0; i < location.Dependencies.Count; i++)
                {
                    CResources.LoadAsync <AssetBundle>(location.Dependencies[i]);
                }
            }
            LogUtility.Log("[Load bundle] " + location.InternalId);

            AssetBundleCreateRequest request = AssetBundle.LoadFromFileAsync(Path.Combine(Path.GetDirectoryName(Application.dataPath), "assetbundles/cresources/" + location.InternalId));

            return(null);
        }