< 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:40
Uncovered lines:6
Coverable lines:46
Total lines:105
Line coverage:86.9% (40 of 46)
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%2.062075%
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;
 20012        public bool visible = true;
 13
 220414        public override GameObject container { get; set; }
 15
 20016        public HashSet<Mesh> meshes = new HashSet<Mesh>();
 20017        public Dictionary<Mesh, int> meshToTriangleCount = new Dictionary<Mesh, int>();
 20018        public HashSet<Renderer> renderers = new HashSet<Renderer>();
 20019        public HashSet<Material> materials = new HashSet<Material>();
 20020        public HashSet<Texture> textures = new HashSet<Texture>();
 21        public int totalTriangleCount = 0;
 22
 23        Coroutine showCoroutine;
 24
 20025        public Asset_GLTF()
 26        {
 20027            container = new GameObject("Asset_GLTF Container");
 20028            visible = true;
 20029        }
 30
 31        public override object Clone()
 32        {
 12933            Asset_GLTF result = this.MemberwiseClone() as Asset_GLTF;
 12934            result.visible = true;
 12935            result.meshes = new HashSet<Mesh>(meshes);
 12936            return result;
 37        }
 38
 39        public override void Cleanup()
 40        {
 41#if UNITY_STANDALONE || UNITY_EDITOR
 20142            if (DataStore.i.common.isApplicationQuitting.Get())
 043                return;
 44#endif
 45
 20146            Object.Destroy(container);
 20147        }
 48
 49        public void Hide()
 50        {
 351            if (container != null)
 52            {
 353                container.transform.parent = null;
 354                container.transform.position = EnvironmentSettings.MORDOR;
 55            }
 56
 357            visible = false;
 358        }
 59
 60        public void CancelShow()
 61        {
 10362            if (showCoroutine != null)
 163                CoroutineStarter.Stop(showCoroutine);
 10364        }
 65
 66        public void Show(bool useMaterialTransition, System.Action OnFinish)
 67        {
 3268            if (showCoroutine != null)
 069                CoroutineStarter.Stop(showCoroutine);
 70
 3271            if (!visible)
 72            {
 073                OnFinish?.Invoke();
 074                return;
 75            }
 76
 3277            bool renderingEnabled = CommonScriptableObjects.rendererState.Get();
 78
 3279            if (!renderingEnabled || !useMaterialTransition)
 80            {
 981                container.SetActive(true);
 982                OnFinish?.Invoke();
 983                return;
 84            }
 85
 2386            showCoroutine = CoroutineStarter.Start(ShowCoroutine(OnFinish));
 2387        }
 88
 89        public IEnumerator ShowCoroutine(System.Action OnFinish)
 90        {
 91            // NOTE(Brian): This fixes seeing the object in the scene 0,0 for a frame
 2392            yield return new WaitForSeconds(Random.Range(0, 0.05f));
 93
 94            // NOTE(Brian): This GameObject can be removed by distance after the delay
 2295            if (container == null)
 96            {
 097                OnFinish?.Invoke();
 098                yield break;
 99            }
 100
 22101            container?.SetActive(true);
 22102            OnFinish?.Invoke();
 22103        }
 104    }
 105}