private void SetupDependencies(string[] dependencies)
        {
            if (dependencies == null || dependencies.Length == 0)
            {
                return;
            }

            if (dependencies.Length > 63)
            {
                throw new Exception($"{ABPath} dependencies count > 64.");
            }

            m_dependencies = new AssetBundleInstance[dependencies.Length];
            var service = CSharpServiceManager.Get <AssetService>(CSharpServiceManager.ServiceType.ASSET_SERVICE);

            for (int i = 0; i < m_dependencies.Length; i++)
            {
                var hash = GenerateHash(dependencies[i]);

                if (!(service.Container.TryGetAsset(hash) is AssetBundleInstance dep))
                {
                    dep = new AssetBundleInstance(dependencies[i]);
                }

                dep.IncRef();
                m_dependencies[i] = dep;
            }
        }
Example #2
0
        public override void SetAsset(Object unityObj, AssetBundleInstance refAssetBundle)
        {
            if (unityObj)
            {
                var prefab      = unityObj as GameObject;
                var cacheConfig = prefab.GetComponent <PoolCacheGO>();
                if (cacheConfig)
                {
                    if (m_pool != null)
                    {
                        throw new Exception("Pool is created!");
                    }

                    m_pool = new AssetPool(prefab.name, cacheConfig.PreferCount, cacheConfig.MaxCount, this);
                }

                m_autoRecyclePrefab = prefab.GetComponent <AutoRecycle>();

#if UNITY_EDITOR
                ChildCountRecursive(prefab.transform);
                m_transformCount++;
#endif
            }

            base.SetAsset(unityObj, refAssetBundle);
        }
Example #3
0
        public void PutAB(AssetBundleInstance ab)
        {
            if (m_abStrategy.TryGetValue(ab.ABPath, out var strategy))
            {
                if (strategy == BundleUnloadStrategy.Normal)
                {
                    m_assets.Add(ab);
                }
            }
            else
            {
                m_assets.Add(ab);
            }

            m_hashAssetDic.Add(ab.GetHashCode(), ab);
        }
Example #4
0
        public virtual void SetAsset(Object unityObj, AssetBundleInstance refAssetBundle)
        {
            UnityObject = unityObj;
            if (refAssetBundle != null)
            {
                RefAssetBundle = refAssetBundle;
                RefAssetBundle.IncRef();
            }
            Status = UnityObject ? AssetStatus.DONE : AssetStatus.FAIL;
            if (Status == AssetStatus.DONE)
            {
                StatService.Get().Increase(StatService.StatName.ASSET_COUNT, 1);
                CreateTime = Time.realtimeSinceStartup;
#if UNITY_DEBUG
                var service = CSharpServiceManager.Get <AssetFullStatService>(CSharpServiceManager.ServiceType.ASSET_FULL_STAT);
                service.OnAssetLoaded(this);
#endif
            }
        }