Exemplo n.º 1
0
        public GameObject InstantiateObject(string path, bool isShowDefaultTrans = false, bool isClear = true)
        {
            uint       crc        = CRC32.GetCRC32(path);
            ObjectItem objectItem = GetCacheObjectItemFromPoolDic(crc);

            if (ReferenceEquals(objectItem, null))
            {
                objectItem         = objectItemNativePool.Spawn();
                objectItem.Crc     = crc;
                objectItem.isClear = isClear;
                objectItem         = ResourceManager.Instance.LoadPrimitiveAssetItem(path, objectItem);

                var PrimitiveAssetObject = objectItem.PrimitiveAssetItem.AssetObject;
                if (PrimitiveAssetObject != null)
                {
                    objectItem.CloneObj    = GameObject.Instantiate(PrimitiveAssetObject) as GameObject;
                    objectItem.OfflineData = objectItem.CloneObj.GetComponent <OfflineData.OfflineData>();
                }
            }

            if (isShowDefaultTrans)
            {
                objectItem.CloneObj.transform.SetParent(SceneTrans, false);
            }

            int guid = objectItem.CloneObj.GetInstanceID();

            if (ObjectItemsInstanceTempDic.ContainsKey(guid) == false)
            {
                ObjectItemsInstanceTempDic.Add(guid, objectItem);
            }

            return(objectItem.CloneObj);
        }
Exemplo n.º 2
0
        public DoubleLinkedListNode <T> AddToHeader(T t)
        {
            DoubleLinkedListNode <T> pList = DoubleLinkNodePool.Spawn();

            pList.next = null;
            pList.prev = null;
            pList.t    = t;
            return(AddToHeader(pList));
        }
Exemplo n.º 3
0
        private AssetBundle LoadAssetBundle(string name)
        {
            AssetBundleItem item = null;
            uint            crc  = CRC32.GetCRC32(name);

            if (!AssetBundleItemDic.TryGetValue(crc, out item))
            {
                AssetBundle assetBundle = null;
                string      path        = P.GetFullPath(Application.streamingAssetsPath, name);
                if (File.Exists(path))
                {
                    assetBundle = AssetBundle.LoadFromFile(path);
                }

                if (assetBundle == null)
                {
                    Debug.LogError($"{MethodBase.GetCurrentMethod().Name} Error: {path} cant load");
                }

                item             = AssetBundleItemPool.Spawn();
                item.AssetBundle = assetBundle;
                AssetBundleItemDic.Add(crc, item);
            }

            item.RefCount++;
            return(item.AssetBundle);
        }
Exemplo n.º 4
0
        public void AsyncLoadResource(string path, OnAsyncFinish cb, LoadResPriority priority, bool isSprite = false,
                                      uint crc = 0,
                                      params object[] paramList)
        {
            if (crc == 0)
            {
                crc = CRC32.GetCRC32(path);
            }

            AssetItem item = GetCacheAssetItem(crc);

            if (item != null)
            {
                cb?.Invoke(path, item.AssetObject, paramList);
                return;
            }

            AsyncLoadAssetParam asyncLoadAssetParam = null;

            if (!asyncLoadAssetParamDic.TryGetValue(crc, out asyncLoadAssetParam))
            {
                asyncLoadAssetParam          = asyncLoadResParamPackPool.Spawn();
                asyncLoadAssetParam.Crc      = crc;
                asyncLoadAssetParam.Path     = path;
                asyncLoadAssetParam.isSprite = isSprite;
                asyncLoadAssetParam.Priority = priority;
                asyncLoadAssetParamDic.Add(crc, asyncLoadAssetParam);
                loadingAssetLists[(int)priority].Add(asyncLoadAssetParam);
            }

            AsyncCallBackPack callBackPack = asyncCallBackPackPool.Spawn();

            callBackPack.AssetFinish = cb;
            callBackPack.paramList   = paramList;
            asyncLoadAssetParam.CallBackPacks.Add(callBackPack);
        }