Ejemplo n.º 1
0
        //归还requester请求的对应的bundle资源
        public void ReturnBundleByName(string requester, string bundle)
        {
#if UNITY_EDITOR
            if (editorMode)
            {
                for (int i = m_cloneNodes.Count - 1; i >= 0; --i)
                {
                    var item = m_cloneNodes[i];
                    if (string.Compare(item.requester, requester, true) == 0)
                    {
                        Destroy(item.cloned);
                        m_cloneNodes.RemoveAt(i);
                    }
                }
                return;
            }
#endif
            if (string.IsNullOrEmpty(requester) || string.IsNullOrEmpty(bundle))
            {
                return;
            }

            AssetRequested assetRequested = null;
            if (!requesterData.TryGetValue(requester, out assetRequested))
            {
                Debug.LogWarning(string.Format("尝试按照名字归还bundle失败:{0},没有关联过这个requester {1}", bundle, requester));
                return;
            }

            //移除后这个requester已经没有任何资源的占用了,移除
            if (assetRequested.ReturnBundle(bundle))
            {
                requesterData.Remove(requester);
            }
        }
Ejemplo n.º 2
0
        private AssetRequested GetAssetRequested(string requester)
        {
            AssetRequested assetRequested = null;

            if (!requesterData.TryGetValue(requester, out assetRequested))
            {
                assetRequested = AssetRequested.Get();
                requesterData.Add(requester, assetRequested);
            }
            return(assetRequested);
        }
Ejemplo n.º 3
0
        //归还requester请求的全部资源
        public void ReturnAllByRequester(string requester)
        {
#if UNITY_EDITOR
            if (editorMode)
            {
                for (int i = m_cloneNodes.Count - 1; i >= 0; --i)
                {
                    var item = m_cloneNodes[i];
                    if (string.Compare(item.requester, requester, true) == 0)
                    {
                        Destroy(item.cloned);
                        m_cloneNodes.RemoveAt(i);
                    }
                }
                return;
            }
#endif

            if (string.IsNullOrEmpty(requester))
            {
                return;
            }

            AssetRequested assetRequested = null;
            if (!requesterData.TryGetValue(requester, out assetRequested))
            {
                return;
            }

            //移除后这个requester已经没有任何资源的占用了,移除
            assetRequested.ReturnAll();

            requesterData.Remove(requester);

            CancleRequest(requester);
        }