< 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:44
Uncovered lines:6
Coverable lines:50
Total lines:111
Line coverage:88% (44 of 50)
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;
 20212        public bool visible = true;
 13
 223214        public override GameObject container { get; set; }
 15
 20216        public HashSet<Mesh> meshes = new HashSet<Mesh>();
 20217        public Dictionary<Mesh, int> meshToTriangleCount = new Dictionary<Mesh, int>();
 20218        public HashSet<Renderer> renderers = new HashSet<Renderer>();
 20219        public HashSet<Material> materials = new HashSet<Material>();
 20220        public HashSet<Texture> textures = new HashSet<Texture>();
 21        public int totalTriangleCount = 0;
 22        public long animationClipSize = 0;
 23        public long meshDataSize = 0;
 24
 25        Coroutine showCoroutine;
 26
 20227        public Asset_GLTF()
 28        {
 20229            container = new GameObject("Asset_GLTF Container");
 20230            visible = true;
 20231        }
 32
 33        public override object Clone()
 34        {
 13135            Asset_GLTF result = this.MemberwiseClone() as Asset_GLTF;
 13136            result.visible = true;
 13137            result.meshes = new HashSet<Mesh>(meshes);
 13138            result.renderers = new HashSet<Renderer>(renderers);
 13139            result.materials = new HashSet<Material>(materials);
 13140            result.textures = new HashSet<Texture>(textures);
 13141            result.meshToTriangleCount = new Dictionary<Mesh, int>(meshToTriangleCount);
 13142            return result;
 43        }
 44
 45        public override void Cleanup()
 46        {
 47#if UNITY_STANDALONE || UNITY_EDITOR
 20348            if (DataStore.i.common.isApplicationQuitting.Get())
 049                return;
 50#endif
 51
 20352            Object.Destroy(container);
 20353        }
 54
 55        public void Hide()
 56        {
 357            if (container != null)
 58            {
 359                container.transform.parent = null;
 360                container.transform.position = EnvironmentSettings.MORDOR;
 61            }
 62
 363            visible = false;
 364        }
 65
 66        public void CancelShow()
 67        {
 10368            if (showCoroutine != null)
 169                CoroutineStarter.Stop(showCoroutine);
 10370        }
 71
 72        public void Show(bool useMaterialTransition, System.Action OnFinish)
 73        {
 3274            if (showCoroutine != null)
 075                CoroutineStarter.Stop(showCoroutine);
 76
 3277            if (!visible)
 78            {
 079                OnFinish?.Invoke();
 080                return;
 81            }
 82
 3283            bool renderingEnabled = CommonScriptableObjects.rendererState.Get();
 84
 3285            if (!renderingEnabled || !useMaterialTransition)
 86            {
 987                container.SetActive(true);
 988                OnFinish?.Invoke();
 989                return;
 90            }
 91
 2392            showCoroutine = CoroutineStarter.Start(ShowCoroutine(OnFinish));
 2393        }
 94
 95        public IEnumerator ShowCoroutine(System.Action OnFinish)
 96        {
 97            // NOTE(Brian): This fixes seeing the object in the scene 0,0 for a frame
 2398            yield return new WaitForSeconds(Random.Range(0, 0.05f));
 99
 100            // NOTE(Brian): This GameObject can be removed by distance after the delay
 22101            if (container == null)
 102            {
 0103                OnFinish?.Invoke();
 0104                yield break;
 105            }
 106
 22107            container?.SetActive(true);
 22108            OnFinish?.Invoke();
 22109        }
 110    }
 111}