< Summary

Class:DCL.Asset_GLTF
Assembly:AssetPromiseKeeper
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/AssetManager/GLTF/Asset_GLTF.cs
Covered lines:36
Uncovered lines:5
Coverable lines:41
Total lines:95
Line coverage:87.8% (36 of 41)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Asset_GLTF()0%110100%
Clone()0%110100%
Cleanup()0%110100%
Hide()0%220100%
CancelShow()0%220100%
Show(...)0%7.777075%
ShowCoroutine()0%8.147071.43%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/AssetManager/GLTF/Asset_GLTF.cs

#LineLine coverage
 1using DCL.Configuration;
 2using System.Collections;
 3using System.Collections.Generic;
 4using UnityEngine;
 5using UnityGLTF;
 6
 7namespace DCL
 8{
 9    public class Asset_GLTF : Asset_WithPoolableContainer
 10    {
 11        public string name;
 11612        public bool visible = true;
 13
 184714        public override GameObject container { get; set; }
 15
 11616        public List<Mesh> meshes = new List<Mesh>();
 11617        public Dictionary<Mesh, int> meshToTriangleCount = new Dictionary<Mesh, int>();
 11618        public List<Renderer> renderers = new List<Renderer>();
 19        public int totalTriangleCount = 0;
 20
 21        Coroutine showCoroutine;
 22
 11623        public Asset_GLTF()
 24        {
 11625            container = new GameObject("Asset_GLTF Container");
 11626            visible = true;
 11627        }
 28
 29        public override object Clone()
 30        {
 12931            Asset_GLTF result = this.MemberwiseClone() as Asset_GLTF;
 12932            result.visible = true;
 12933            result.meshes = new List<Mesh>(meshes);
 12934            return result;
 35        }
 36
 23437        public override void Cleanup() { Object.Destroy(container); }
 38
 39        public void Hide()
 40        {
 341            if (container != null)
 42            {
 343                container.transform.parent = null;
 344                container.transform.position = EnvironmentSettings.MORDOR;
 45            }
 46
 347            visible = false;
 348        }
 49
 50        public void CancelShow()
 51        {
 1752            if (showCoroutine != null)
 253                CoroutineStarter.Stop(showCoroutine);
 1754        }
 55
 56        public void Show(bool useMaterialTransition, System.Action OnFinish)
 57        {
 2958            if (showCoroutine != null)
 059                CoroutineStarter.Stop(showCoroutine);
 60
 2961            if (!visible)
 62            {
 063                OnFinish?.Invoke();
 064                return;
 65            }
 66
 2967            bool renderingEnabled = CommonScriptableObjects.rendererState.Get();
 68
 2969            if (!renderingEnabled || !useMaterialTransition)
 70            {
 571                container.SetActive(true);
 572                OnFinish?.Invoke();
 573                return;
 74            }
 75
 2476            showCoroutine = CoroutineStarter.Start(ShowCoroutine(OnFinish));
 2477        }
 78
 79        public IEnumerator ShowCoroutine(System.Action OnFinish)
 80        {
 81            // NOTE(Brian): This fixes seeing the object in the scene 0,0 for a frame
 2482            yield return new WaitForSeconds(Random.Range(0, 0.05f));
 83
 84            // NOTE(Brian): This GameObject can be removed by distance after the delay
 2285            if (container == null)
 86            {
 087                OnFinish?.Invoke();
 088                yield break;
 89            }
 90
 2291            container?.SetActive(true);
 2292            OnFinish?.Invoke();
 2293        }
 94    }
 95}