Exemplo n.º 1
0
        /// <summary>
        /// Called when any loading error occurs.
        /// </summary>
        /// <param name="contextualizedError">Thrown error containing an attached context.</param>
        private static void OnError(IContextualizedError contextualizedError)
        {
            var assetLoaderContext       = contextualizedError?.GetContext() as AssetLoaderContext;
            var zipLoadCustomContextData = assetLoaderContext?.CustomData as ZipLoadCustomContextData;

            zipLoadCustomContextData?.Stream.Close();
            zipLoadCustomContextData?.OnError?.Invoke(contextualizedError);
        }
Exemplo n.º 2
0
        /// <summary>Event triggered when there is any Model loading error.</summary>
        /// <param name="contextualizedError">The Contextualized Error that has occurred.</param>
        protected override void OnError(IContextualizedError contextualizedError)
        {
            var context = contextualizedError.GetContext();

            if (context is AssetLoaderContext assetLoaderContext)
            {
                var zipLoadCustomContextData = (ZipLoadCustomContextData)assetLoaderContext.CustomData;
                var uriLoadCustomContextData = (UriLoadCustomContextData)zipLoadCustomContextData.CustomData;
                var downloaded = Instantiate(_downloadTemplate, _downloadTemplate.transform.parent);
                var text       = downloaded.GetComponentInChildren <Text>();
                text.text = $"Error: {uriLoadCustomContextData.UnityWebRequest.uri.Segments[uriLoadCustomContextData.UnityWebRequest.uri.Segments.Length - 1]}";
                downloaded.SetActive(true);
            }
            base.OnError(contextualizedError);
        }