Esempio n. 1
0
    void CacheResource(string path, ref ResourceItem item, uint crc, Object obj, int addrefcount = 1)
    {
        WashOut();
        if (item == null)
        {
            Debug.LogError("ResourceItem is null " + path);
            return;
        }

        if (obj == null)
        {
            Debug.LogError("ResourceLoad Fail " + path);
            return;
        }
        item.m_Obj         = obj;
        item.m_Guid        = obj.GetInstanceID();
        item.m_LastUseTime = Time.realtimeSinceStartup;
        item.Retain(addrefcount);
        ResourceItem oldItem = null;

        if (AssetDic.TryGetValue(item.m_Crc, out oldItem))//更新
        {
            AssetDic[item.m_Crc] = item;
        }
        else
        {
            AssetDic.Add(item.m_Crc, item);
        }
    }
Esempio n. 2
0
    ResourceItem GetCacheResourceItem(uint crc, int addrefcount = 1)
    {
        ResourceItem item = null;

        if (AssetDic.TryGetValue(crc, out item) && item != null)
        {
            item.Retain(addrefcount);
            item.m_LastUseTime = Time.realtimeSinceStartup;
        }

        return(item);
    }
Esempio n. 3
0
    ResourceItem GetCacheResourceItem(uint crc, int addrefcount = 1)
    {
        ResourceItem item = null;

        if (AssetDic.TryGetValue(crc, out item))
        {
            if (item != null)
            {
                item.Retain(addrefcount);
                item.m_LastUseTime = Time.realtimeSinceStartup;
                //if (item.RefCount <= 1)
                //{
                //    m_NoRefrenceAssetMapList.Remove(item);
                //}
            }
        }

        return(item);
    }