Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using OSGraphicsAPI;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Threading.Tasks;
- using UnityEngine;
- using Zenject;
- public interface ISkyboxCubemapLoader
- {
- event Action<TourPoint, Cubemap> OnCubemapLoaded;
- }
- public class SkyboxCubemapLoader : ITourPointResourceDependencyHolder, ISkyboxCubemapLoader
- {
- [Inject]
- private ITourController tourController;
- [Inject]
- private ITaskRunner taskRunner;
- [Inject]
- private ICacheManager cacheManager;
- public event Action<TourPoint, Cubemap> OnCubemapLoaded;
- void ITourPointResourceDependencyHolder.SatisfyDependency(TourPoint point, Action onComplete)
- {
- var loadedCubemap = new Cubemap(tourController.CurrentTour.MaxResolution, TextureFormat.RGBA32, false);
- var pointer = loadedCubemap.GetNativeTexturePtr();
- Task.Factory.StartNew(() =>
- {
- var skyboxPath = cacheManager.GetCacheSkyboxPathes(tourController.CurrentEstate.Id, tourController.CurrentTour.Id, point.Skybox.Id, tourController.CurrentTour.MaxResolution);
- Loader.LoadCubemapInternal(pointer, skyboxPath);
- taskRunner.ExecuteInMainThreadUpdate(() =>
- {
- if (OnCubemapLoaded != null)
- OnCubemapLoaded(point, loadedCubemap);
- });
- taskRunner.ExecuteInMainThreadUpdate(onComplete);
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement