private T GetCachedInstance <T>(int key) where T : Object
        {
            List <InstanceInfo> list;

            if (!mCachedInstances.TryGetValue(key, out list))
            {
                return(null);
            }
            T ret = null;

            while (0 < list.Count)
            {
                InstanceInfo instance = list[0];
                list.RemoveAt(0);
                if (instance.obj != null && !instance.obj.Equals(null))
                {
                    List <InstanceInfo> usingList = GetUsingInstanceList(key);
                    usingList.Add(instance);
                    ret = instance.obj as T;
                    break;
                }
                Debug.LogErrorFormat("[ResourcesHolder] GetCachedInstance() Object instance of '{0}' is destroyed unexpectedly",
                                     HashString.GetString(key));
            }
            if (list.Count <= 0)
            {
                mCachedInstances.Remove(key);
                cached_instance_list.Enqueue(list);
            }
            return(ret);
        }
Exemplo n.º 2
0
        private void OnLoaded2(LoadingData loadingData, Object obj)
        {
            int  key  = loadingData.key;
            bool flag = mLoadings.Remove(key);

            loadingData.Clear();
            cached_loading_lists.Enqueue(loadingData);
            if (!flag)
            {
                Debug.LogErrorFormat("[ResourcesHolder] in OnLoaded() No callbacks found for '{0}' !",
                                     HashString.GetString(key));
            }
        }
Exemplo n.º 3
0
        private void OnLoaded1(LoadingData loadingData, Object obj, int count)
        {
            if (obj == null)
            {
                Debug.LogErrorFormat("[ResourcesHolder] Fail to load file '{0}' !", HashString.GetString(loadingData.key));
                return;
            }
            ResourcesData data = CreateResourcesData(loadingData.type, obj);

            data.refCount = count;
            mLoaded.Add(loadingData.key, data);
            mResourcesToPath.Add(GetResourcesKey(loadingData.type, obj), loadingData.key);
        }
Exemplo n.º 4
0
        private bool ReleaseResourcesInternal(Type type, Object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            int key;

            if (!mResourcesToPath.TryGetValue(GetResourcesKey(type, obj), out key))
            {
                Debug.LogWarningFormat("[ResourcesHolder] ReleaseResourcesInternal() resource '{0}' not managed !", obj);
                return(false);
            }
            ResourcesData data;

            if (!mLoaded.TryGetValue(key, out data))
            {
                Debug.LogWarningFormat("[ResourcesHolder] ReleaseResourcesInternal() resource '{0}' not managed !", HashString.GetString(key));
                return(false);
            }
            data.refCount--;
            return(true);
        }