< 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:84
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%110100%
CancelShow()0%220100%
Show(...)0%7.67076.92%
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;
 4
 5namespace DCL
 6{
 7    public class Asset_GLTF : Asset_WithPoolableContainer
 8    {
 13059        public override GameObject container { get; set; }
 10        public string name;
 8511        public bool visible = true;
 12
 13        Coroutine showCoroutine;
 14
 8515        public Asset_GLTF()
 16        {
 8517            container = new GameObject();
 8518            container.name = "Asset_GLTF Container";
 8519            visible = true;
 8520        }
 21
 22        public override object Clone()
 23        {
 8424            Asset_GLTF result = this.MemberwiseClone() as Asset_GLTF;
 8425            result.visible = true;
 8426            return result;
 27        }
 28
 17029        public override void Cleanup() { Object.Destroy(container); }
 30
 31        public void Hide()
 32        {
 233            container.transform.parent = null;
 234            container.transform.position = EnvironmentSettings.MORDOR;
 235            visible = false;
 236        }
 37
 38        public void CancelShow()
 39        {
 2740            if (showCoroutine != null)
 241                CoroutineStarter.Stop(showCoroutine);
 2742        }
 43
 44        public void Show(bool useMaterialTransition, System.Action OnFinish)
 45        {
 2646            if (showCoroutine != null)
 047                CoroutineStarter.Stop(showCoroutine);
 48
 2649            if (!visible)
 50            {
 051                OnFinish?.Invoke();
 052                return;
 53            }
 54
 2655            bool renderingEnabled = CommonScriptableObjects.rendererState.Get();
 56
 2657            if (!renderingEnabled || !useMaterialTransition)
 58            {
 259                container.SetActive(true);
 260                OnFinish?.Invoke();
 261                return;
 62            }
 63
 2464            container.SetActive(false);
 2465            showCoroutine = CoroutineStarter.Start(ShowCoroutine(OnFinish));
 2466        }
 67
 68        public IEnumerator ShowCoroutine(System.Action OnFinish)
 69        {
 70            // NOTE(Brian): This fixes seeing the object in the scene 0,0 for a frame
 2471            yield return new WaitForSeconds(Random.Range(0, 0.05f));
 72
 73            // NOTE(Brian): This GameObject can be removed by distance after the delay
 2274            if (container == null)
 75            {
 076                OnFinish?.Invoke();
 077                yield break;
 78            }
 79
 2280            container?.SetActive(true);
 2281            OnFinish?.Invoke();
 2282        }
 83    }
 84}