< Summary

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

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Unload()0%110100%
Load(...)0%4.254075%
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        {
 114            objLoaderComponent.OnFinishedLoadingAsset -= SuccessWrapper;
 115            Object.Destroy(objLoaderComponent);
 116            entity.Cleanup();
 117        }
 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);
 37            }
 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}