< Summary

Class:DCL.Components.LoadWrapper_GLTF
Assembly:MainScripts
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/LoadableShapes/LoadWrapper/LoadWrapper_GLTF.cs
Covered lines:29
Uncovered lines:5
Coverable lines:34
Total lines:79
Line coverage:85.2% (29 of 34)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Load(...)0%6.226081.82%
OnFailWrapper(...)0%220100%
OnSuccessWrapper(...)0%220100%
OnEntityCleanup(...)0%110100%
Unload()0%110100%
ToString()0%2100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/LoadableShapes/LoadWrapper/LoadWrapper_GLTF.cs

#LineLine coverage
 1using System;
 2using UnityEngine;
 3using UnityEngine.Assertions;
 4
 5namespace DCL.Components
 6{
 7
 8    public class LoadWrapper_GLTF : LoadWrapper
 9    {
 10        static readonly bool VERBOSE = false;
 11        RendereableAssetLoadHelper loadHelper;
 12        public ContentProvider customContentProvider;
 13
 14        public override void Load(string targetUrl, Action<LoadWrapper> OnSuccess, Action<LoadWrapper> OnFail)
 15        {
 7816            if (loadHelper != null)
 17            {
 218                loadHelper.Unload();
 19
 220                if (VERBOSE)
 021                    Debug.Log("Forgetting not null loader...");
 22            }
 23
 7824            alreadyLoaded = false;
 7825            Assert.IsFalse(string.IsNullOrEmpty(targetUrl), "url is null!!");
 26
 27
 7828            if (customContentProvider == null)
 029                loadHelper = new RendereableAssetLoadHelper(this.entity.scene.contentProvider, entity.scene.sceneData.ba
 30            else
 7831                loadHelper = new RendereableAssetLoadHelper(customContentProvider, entity.scene.sceneData.baseUrlBundles
 32
 33
 7834            loadHelper.settings.parent = entity.meshRootGameObject.transform;
 35
 7836            if (initialVisibility == false)
 37            {
 038                loadHelper.settings.visibleFlags = AssetPromiseSettings_Rendering.VisibleFlags.INVISIBLE;
 039            }
 40            else
 41            {
 7842                if (useVisualFeedback)
 143                    loadHelper.settings.visibleFlags = AssetPromiseSettings_Rendering.VisibleFlags.VISIBLE_WITH_TRANSITI
 44                else
 7745                    loadHelper.settings.visibleFlags = AssetPromiseSettings_Rendering.VisibleFlags.VISIBLE_WITHOUT_TRANS
 46            }
 47
 7848            this.entity.OnCleanupEvent -= OnEntityCleanup;
 7849            this.entity.OnCleanupEvent += OnEntityCleanup;
 50
 13451            loadHelper.OnSuccessEvent += (x) => OnSuccessWrapper(OnSuccess);
 8152            loadHelper.OnFailEvent += () => OnFailWrapper(OnFail);
 7853            loadHelper.Load(targetUrl);
 7854        }
 55
 56        private void OnFailWrapper(Action<LoadWrapper> OnFail)
 57        {
 358            alreadyLoaded = true;
 359            this.entity.OnCleanupEvent -= OnEntityCleanup;
 360            OnFail?.Invoke(this);
 361        }
 62
 63        private void OnSuccessWrapper(Action<LoadWrapper> OnSuccess)
 64        {
 5665            alreadyLoaded = true;
 5666            OnSuccess?.Invoke(this);
 5667        }
 68
 269        public void OnEntityCleanup(ICleanableEventDispatcher source) { Unload(); }
 70
 71        public override void Unload()
 72        {
 7073            loadHelper.Unload();
 7074            this.entity.OnCleanupEvent -= OnEntityCleanup;
 7075        }
 76
 077        public override string ToString() { return $"LoadWrapper ... {loadHelper.ToString()}"; }
 78    }
 79}