Example #1
0
        /// <summary>
        /// Asynchronously loads the scene a the given <paramref name="location"/>.
        /// </summary>
        /// <returns>Async operation for the scene.</returns>
        /// <param name="location">location of the scene to load.</param>
        /// <param name="loadMode">Scene Load mode.</param>
        public static IAsyncOperation <Scene> ProvideScene(IResourceLocation location, LoadSceneMode loadMode = LoadSceneMode.Single)
        {
            if (SceneProvider == null)
            {
                throw new NullReferenceException("ResourceManager.SceneProvider is null.  Assign a valid ISceneProvider object before using.");
            }
            if (location == null)
            {
                return(new CompletedOperation <Scene>().Start(null, null, default(Scene), new ArgumentNullException("location")));
            }

            ResourceManagerEventCollector.PostEvent(ResourceManagerEventCollector.EventType.LoadSceneAsyncRequest, location, 1);
            ResourceManagerEventCollector.PostEvent(ResourceManagerEventCollector.EventType.CacheEntryLoadPercent, location, 0);

            return(SceneProvider.ProvideSceneAsync(location, LoadDependencies(location), loadMode).Retain());
        }