< 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:46
Uncovered lines:6
Coverable lines:52
Total lines:117
Line coverage:88.4% (46 of 52)
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        private const string CONTAINER_GO_NAME = "Asset_GLTF Container";
 12
 13        public string name;
 11714        public bool visible = true;
 15
 203816        public override GameObject container { get; set; }
 17
 11718        public HashSet<Mesh> meshes = new HashSet<Mesh>();
 11719        public Dictionary<Mesh, int> meshToTriangleCount = new Dictionary<Mesh, int>();
 11720        public HashSet<Renderer> renderers = new HashSet<Renderer>();
 11721        public HashSet<Material> materials = new HashSet<Material>();
 11722        public HashSet<Texture> textures = new HashSet<Texture>();
 11723        public HashSet<AnimationClip> animationClips = new HashSet<AnimationClip>();
 24        public int totalTriangleCount = 0;
 25        public long animationClipSize = 0;
 26        public long meshDataSize = 0;
 27
 28        Coroutine showCoroutine;
 29
 11730        public Asset_GLTF()
 31        {
 11732            container = new GameObject(CONTAINER_GO_NAME);
 33            // Hide gameobject until it's been correctly processed, otherwise it flashes at 0,0,0
 11734            container.transform.position = EnvironmentSettings.MORDOR;
 11735        }
 36
 37        public override object Clone()
 38        {
 13839            Asset_GLTF result = this.MemberwiseClone() as Asset_GLTF;
 13840            result.visible = true;
 13841            result.meshes = new HashSet<Mesh>(meshes);
 13842            result.renderers = new HashSet<Renderer>(renderers);
 13843            result.materials = new HashSet<Material>(materials);
 13844            result.textures = new HashSet<Texture>(textures);
 13845            result.meshToTriangleCount = new Dictionary<Mesh, int>(meshToTriangleCount);
 13846            result.animationClips = new HashSet<AnimationClip>(animationClips);
 47
 13848            return result;
 49        }
 50
 51        public override void Cleanup()
 52        {
 53#if UNITY_STANDALONE || UNITY_EDITOR
 14954            if (DataStore.i.common.isApplicationQuitting.Get())
 055                return;
 56#endif
 57
 14958            Object.Destroy(container);
 14959        }
 60
 61        public void Hide()
 62        {
 363            if (container != null)
 64            {
 365                container.transform.parent = null;
 366                container.transform.position = EnvironmentSettings.MORDOR;
 67            }
 68
 369            visible = false;
 370        }
 71
 72        public void CancelShow()
 73        {
 1474            if (showCoroutine != null)
 175                CoroutineStarter.Stop(showCoroutine);
 1476        }
 77
 78        public void Show(bool useMaterialTransition, System.Action OnFinish)
 79        {
 3580            if (showCoroutine != null)
 081                CoroutineStarter.Stop(showCoroutine);
 82
 3583            if (!visible)
 84            {
 085                OnFinish?.Invoke();
 086                return;
 87            }
 88
 3589            bool renderingEnabled = CommonScriptableObjects.rendererState.Get();
 90
 3591            if (!renderingEnabled || !useMaterialTransition)
 92            {
 1293                container.SetActive(true);
 1294                OnFinish?.Invoke();
 1295                return;
 96            }
 97
 2398            showCoroutine = CoroutineStarter.Start(ShowCoroutine(OnFinish));
 2399        }
 100
 101        public IEnumerator ShowCoroutine(System.Action OnFinish)
 102        {
 103            // NOTE(Brian): This fixes seeing the object in the scene 0,0 for a frame
 23104            yield return new WaitForSeconds(Random.Range(0, 0.05f));
 105
 106            // NOTE(Brian): This GameObject can be removed by distance after the delay
 22107            if (container == null)
 108            {
 0109                OnFinish?.Invoke();
 0110                yield break;
 111            }
 112
 22113            container?.SetActive(true);
 22114            OnFinish?.Invoke();
 22115        }
 116    }
 117}