< 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:33
Uncovered lines:5
Coverable lines:38
Total lines:87
Line coverage:86.8% (33 of 38)
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 UnityEngine;
 4using UnityGLTF;
 5
 6namespace DCL
 7{
 8    public class Asset_GLTF : Asset_WithPoolableContainer
 9    {
 187310        public override GameObject container { get; set; }
 11        public string name;
 11112        public bool visible = true;
 13
 14        Coroutine showCoroutine;
 15
 11116        public Asset_GLTF()
 17        {
 11118            container = new GameObject();
 11119            container.name = "Asset_GLTF Container";
 11120            visible = true;
 11121        }
 22
 23        public override object Clone()
 24        {
 11325            Asset_GLTF result = this.MemberwiseClone() as Asset_GLTF;
 11326            result.visible = true;
 11327            return result;
 28        }
 29
 22230        public override void Cleanup() { Object.Destroy(container); }
 31
 32        public void Hide()
 33        {
 2334            if (container != null)
 35            {
 2336                container.transform.parent = null;
 2337                container.transform.position = EnvironmentSettings.MORDOR;
 38            }
 2339            visible = false;
 2340        }
 41
 42        public void CancelShow()
 43        {
 744            if (showCoroutine != null)
 145                CoroutineStarter.Stop(showCoroutine);
 746        }
 47
 48        public void Show(bool useMaterialTransition, System.Action OnFinish)
 49        {
 2650            if (showCoroutine != null)
 051                CoroutineStarter.Stop(showCoroutine);
 52
 2653            if (!visible)
 54            {
 055                OnFinish?.Invoke();
 056                return;
 57            }
 58
 2659            bool renderingEnabled = CommonScriptableObjects.rendererState.Get();
 60
 2661            if (!renderingEnabled || !useMaterialTransition)
 62            {
 263                container.SetActive(true);
 264                OnFinish?.Invoke();
 265                return;
 66            }
 67
 2468            showCoroutine = CoroutineStarter.Start(ShowCoroutine(OnFinish));
 2469        }
 70
 71        public IEnumerator ShowCoroutine(System.Action OnFinish)
 72        {
 73            // NOTE(Brian): This fixes seeing the object in the scene 0,0 for a frame
 2474            yield return new WaitForSeconds(Random.Range(0, 0.05f));
 75
 76            // NOTE(Brian): This GameObject can be removed by distance after the delay
 2377            if (container == null)
 78            {
 079                OnFinish?.Invoke();
 080                yield break;
 81            }
 82
 2383            container?.SetActive(true);
 2384            OnFinish?.Invoke();
 2385        }
 86    }
 87}