private void MakeEntity(EntityId entityId, string prefabName, Action <EntityId, string> onSuccess) { entitiesToSpawn[entityId].IsLoading = true; templateProvider.PrepareTemplate(prefabName, _ => { onSuccess(entityId, prefabName); }, exception => { Debug.LogError("Exception occurred when preparing " + prefabName + " template. " + exception); }); }
private void StartPrecachingAsset() { var assetToPrecache = assetsToPrecache[nextAssetToPrecacheIndex]; OnAssetPrecacheStarted(assetToPrecache); entityTemplateProvider.PrepareTemplate(assetToPrecache, OnAssetPrecached, ex => OnAssetPrecacheFailed(assetToPrecache, ex)); }
private void PrePoolAssets() { if (assetsToPrePool == null || !assetsToPrePool.Any()) { return; } foreach (var prefabNameToCount in assetsToPrePool) { // Prepooling only supports default context at the moment. Ultimately all this code should be pulled out into user code. var requestedCountInPool = prefabNameToCount.Value; templateProvider.PrepareTemplate(prefabNameToCount.Key, prefabName => { var prefab = templateProvider.GetEntityTemplate(prefabName); prefabPool.PreparePool(prefab, prefabName, requestedCountInPool); }, exception => Debug.LogErrorFormat("Problem initialising pool for entity {0}: {1}", prefabNameToCount.Key, exception.Message)); } }