IEnumerator EndOfFrame()
        {
            while (true)
            {
                yield return(new WaitForEndOfFrame());

                VectorLineUpdater.UpdateAllLines();
            }
        }
        public static void VisualizeRenderers(List <Renderer> renderers, int type)
        {
            var skins = renderers.Select(x => x as SkinnedMeshRenderer).Where(x => x);

            foreach (var skin in skins)
            {
                skin.updateWhenOffscreen = true;
            }

            if ((type & 1) != 0)
            {
                var bounds3d = new VectorLineUpdater();
                bounds3d.VectorLine = new VectorLine("Bounds3D", new List <Vector3>(24), 1f, LineType.Discrete);
                bounds3d.Update     = () =>
                {
                    var bounds = CombineBounds(renderers);
                    bounds3d.VectorLine.MakeCube(bounds.center, bounds.size.x, bounds.size.y, bounds.size.z);
                    bounds3d.VectorLine.SetColor(Color.red);
                    bounds3d.VectorLine.Draw();
                };
            }

            if ((type & 2) != 0)
            {
                var bounds2d = new VectorLineUpdater();
                bounds2d.VectorLine = new VectorLine("Bounds2D", new List <Vector2>(8), 1f, LineType.Discrete);
                bounds2d.Update     = () =>
                {
                    var bounds = CombineBounds(renderers);
                    var rect   = BoundsToScreenRect(bounds, Camera.main);
                    bounds2d.VectorLine.MakeRect(rect);
                    bounds2d.VectorLine.SetColor(Color.green);
                    bounds2d.VectorLine.Draw();
                };
            }
        }
 void OnDestroy()
 {
     VectorLineUpdater.DeleteAllLines();
 }