< Summary

Class:DCL.Components.LoadWrapper_OBJ
Assembly:MainScripts
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Components/LoadableShapes/LoadWrapper/LoadWrapper_OBJ.cs
Covered lines:19
Uncovered lines:7
Coverable lines:26
Total lines:64
Line coverage:73% (19 of 26)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Unload()0%2100%
Load(...)0%4.24076.92%
SuccessWrapper()0%220100%
CallOnComponentUpdated()0%330100%

File(s)

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

#LineLine coverage
 1using System;
 2using DCL.Helpers;
 3using Object = UnityEngine.Object;
 4
 5namespace DCL.Components
 6{
 7    public class LoadWrapper_OBJ : LoadWrapper
 8    {
 9        DynamicOBJLoaderController objLoaderComponent;
 10        System.Action<LoadWrapper> OnSuccessEvent;
 11
 12        public override void Unload()
 13        {
 014            objLoaderComponent.OnFinishedLoadingAsset -= SuccessWrapper;
 015            Object.Destroy(objLoaderComponent);
 016            entity.Cleanup();
 017        }
 18
 19        public override void Load(string src, System.Action<LoadWrapper> OnSuccess, System.Action<LoadWrapper, Exception
 20        {
 121            if (string.IsNullOrEmpty(src))
 022                return;
 23
 124            if (objLoaderComponent == null)
 125                objLoaderComponent = entity.meshRootGameObject.GetOrCreateComponent<DynamicOBJLoaderController>();
 26
 127            objLoaderComponent.OnFinishedLoadingAsset += SuccessWrapper;
 128            OnSuccessEvent = OnSuccess;
 29
 130            alreadyLoaded = false;
 131            objLoaderComponent.LoadAsset(src, true);
 32
 133            if (objLoaderComponent.loadingPlaceholder == null)
 34            {
 135                objLoaderComponent.loadingPlaceholder =
 36                    Helpers.Utils.AttachPlaceholderRendererGameObject(entity.gameObject.transform);
 137            }
 38            else
 39            {
 040                objLoaderComponent.loadingPlaceholder.SetActive(true);
 41            }
 042        }
 43
 44        void SuccessWrapper()
 45        {
 146            CallOnComponentUpdated();
 147            OnSuccessEvent?.Invoke(this);
 148        }
 49
 50        void CallOnComponentUpdated()
 51        {
 152            alreadyLoaded = true;
 53
 154            if (entity.OnShapeUpdated != null)
 55            {
 156                entity.OnShapeUpdated.Invoke(entity);
 57            }
 158            entity.OnShapeLoaded?.Invoke(entity);
 59
 160            CollidersManager.i.ConfigureColliders(entity);
 161        }
 62
 63    }
 64}