public void LoadSceneAsync(AssetInfo assetInfo, bool isAdditive) { _logger.InfoFormat("LoadSeneAsync {0}", assetInfo); var req = AssetLoadRequest <object> .Alloc(); req.Source = null; req.AssetInfo = assetInfo; req.OnLoaded = null; req.RequestType = ELoadRequestType.Scene; req.IsAdditiveScene = isAdditive; _pendingRequests.AddLast(req); }
public void LoadAssetBundleAsync(string bundleName) { var req = AssetLoadRequest <object> .Alloc(); req.Source = null; req.OnLoaded = null; req.AssetInfo = new AssetInfo() { BundleName = bundleName, AssetName = null }; req.RequestType = ELoadRequestType.Bundle; _pendingRequests.AddLast(req); }
private AssetLoadRequest <T> AppendAssetRequest <T>(T source, AssetInfo assetInfo, Action <T, UnityObject> handlerAction, AssetLoadOption option) { _logger.DebugFormat("***** ***** ***** Loading Asset {0}", assetInfo); var req = AssetLoadRequest <T> .Alloc(); req.Source = source; req.AssetInfo = assetInfo; req.OnLoaded = handlerAction; req.RequestType = ELoadRequestType.Asset; req.Option = option; if (assetInfo.BundleName == null || assetInfo.AssetName == null) { try { throw new ArgumentNullException(string.Format("Loading Asset {0} is Invalid", assetInfo)); } catch (Exception e) { _logger.ErrorFormat("Loading Asset {0} is Invalid from {1}", assetInfo, e); } req.IsDisposed = true; return(req); } var profiler = SingletonManager.Get <LoadRequestProfileHelp>().GetProfile(assetInfo); profiler.RequestTimes++; var unityObj = _objectPool.GetOrNull(assetInfo, req.AutoActive); if (unityObj != null) { profiler.PooledTimes++; if (req.Parent != null) { var transform = req.Parent.transform; var go = unityObj.AsGameObject; if (go != null && go.transform.parent != transform) { go.transform.SetParent(transform, false); } } unityObj.OnLoadFromPool(); req.LoadedObject = unityObj; _loadedRequests.Enqueue(req); _logger.InfoFormat("Load resource for object pool {0}", assetInfo); } else { _pendingRequests.AddLast(req); } return(req); }