예제 #1
0
        public static void RemoveCachedResources(enResourceType resourceType, bool clearImmediately = true)
        {
            List <int> list = new List <int>();

            Dictionary <int, CResource> .Enumerator enumerator = m_cachedResourceMap.GetEnumerator();
            while (enumerator.MoveNext())
            {
                KeyValuePair <int, CResource> current = enumerator.Current;
                CResource resource = current.Value;
                if (resource.m_resourceType == resourceType)
                {
                    resource.Unload();
                    list.Add(resource.m_key);
                }
            }
            for (int i = 0; i < list.Count; i++)
            {
                m_cachedResourceMap.Remove(list[i]);
            }
            if (clearImmediately)
            {
                //this.UnloadAllAssetBundles();
                UnloadUnusedAssets();
            }
        }
예제 #2
0
        public void RemoveCachedResource(string fullPathInResources)
        {
            //int key = CFileManager.EraseExtension(fullPathInResources).JavaHashCodeIgnoreCase();
            int key = CFileManager.EraseExtension(fullPathInResources).GetHashCode();

            CResource resource = null;

            if (m_cachedResourceMap.TryGetValue(key, out resource))
            {
                resource.Unload();
                m_cachedResourceMap.Remove(key);
            }
        }
예제 #3
0
        public static CResource GetResource(string fullPathInResources, Type resourceContentType, enResourceType resourceType, bool needCached = false, bool unloadBelongedAssetBundleAfterLoaded = false)
        {
            if (string.IsNullOrEmpty(fullPathInResources))
            {
                return(new CResource(0, string.Empty, null, resourceType, unloadBelongedAssetBundleAfterLoaded));
            }
            string s = CFileManager.EraseExtension(fullPathInResources);

            //int key = s.JavaHashCodeIgnoreCase();
            int key = s.GetHashCode();

            CResource resource = null;

            if (m_cachedResourceMap.TryGetValue(key, out resource))
            {
                if (resource.m_resourceType != resourceType)
                {
                    resource.m_resourceType = resourceType;
                }
                return(resource);
            }
            resource = new CResource(key, fullPathInResources, resourceContentType, resourceType, unloadBelongedAssetBundleAfterLoaded);
            try
            {
                LoadResource(resource);
            }
            catch (Exception exception)
            {
                object[] inParameters = new object[] { s };
                //DebugHelper.Assert(false, "Failed Load Resource {0}", inParameters);
                throw exception;
            }
            if (needCached)
            {
                m_cachedResourceMap.Add(key, resource);
            }
            return(resource);
        }
예제 #4
0
 private static void LoadResource(CResource resource)
 {
     resource.Load();
 }