< 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:114
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        public string name;
 21212        public bool visible = true;
 13
 226814        public override GameObject container { get; set; }
 15
 21216        public HashSet<Mesh> meshes = new HashSet<Mesh>();
 21217        public Dictionary<Mesh, int> meshToTriangleCount = new Dictionary<Mesh, int>();
 21218        public HashSet<Renderer> renderers = new HashSet<Renderer>();
 21219        public HashSet<Material> materials = new HashSet<Material>();
 21220        public HashSet<Texture> textures = new HashSet<Texture>();
 21221        public HashSet<AnimationClip> animationClips = new HashSet<AnimationClip>();
 22        public int totalTriangleCount = 0;
 23        public long animationClipSize = 0;
 24        public long meshDataSize = 0;
 25
 26        Coroutine showCoroutine;
 27
 21228        public Asset_GLTF()
 29        {
 21230            container = new GameObject("Asset_GLTF Container");
 21231            visible = true;
 21232        }
 33
 34        public override object Clone()
 35        {
 13536            Asset_GLTF result = this.MemberwiseClone() as Asset_GLTF;
 13537            result.visible = true;
 13538            result.meshes = new HashSet<Mesh>(meshes);
 13539            result.renderers = new HashSet<Renderer>(renderers);
 13540            result.materials = new HashSet<Material>(materials);
 13541            result.textures = new HashSet<Texture>(textures);
 13542            result.meshToTriangleCount = new Dictionary<Mesh, int>(meshToTriangleCount);
 13543            result.animationClips = new HashSet<AnimationClip>(animationClips);
 44
 13545            return result;
 46        }
 47
 48        public override void Cleanup()
 49        {
 50#if UNITY_STANDALONE || UNITY_EDITOR
 25051            if (DataStore.i.common.isApplicationQuitting.Get())
 052                return;
 53#endif
 54
 25055            Object.Destroy(container);
 25056        }
 57
 58        public void Hide()
 59        {
 360            if (container != null)
 61            {
 362                container.transform.parent = null;
 363                container.transform.position = EnvironmentSettings.MORDOR;
 64            }
 65
 366            visible = false;
 367        }
 68
 69        public void CancelShow()
 70        {
 11071            if (showCoroutine != null)
 172                CoroutineStarter.Stop(showCoroutine);
 11073        }
 74
 75        public void Show(bool useMaterialTransition, System.Action OnFinish)
 76        {
 3377            if (showCoroutine != null)
 078                CoroutineStarter.Stop(showCoroutine);
 79
 3380            if (!visible)
 81            {
 082                OnFinish?.Invoke();
 083                return;
 84            }
 85
 3386            bool renderingEnabled = CommonScriptableObjects.rendererState.Get();
 87
 3388            if (!renderingEnabled || !useMaterialTransition)
 89            {
 1090                container.SetActive(true);
 1091                OnFinish?.Invoke();
 1092                return;
 93            }
 94
 2395            showCoroutine = CoroutineStarter.Start(ShowCoroutine(OnFinish));
 2396        }
 97
 98        public IEnumerator ShowCoroutine(System.Action OnFinish)
 99        {
 100            // NOTE(Brian): This fixes seeing the object in the scene 0,0 for a frame
 23101            yield return new WaitForSeconds(Random.Range(0, 0.05f));
 102
 103            // NOTE(Brian): This GameObject can be removed by distance after the delay
 22104            if (container == null)
 105            {
 0106                OnFinish?.Invoke();
 0107                yield break;
 108            }
 109
 22110            container?.SetActive(true);
 22111            OnFinish?.Invoke();
 22112        }
 113    }
 114}