Example #1
0
        private void Render(CableRoute route, float radius)
        {
            if (m_segmentSpawner == null)
            {
                return;
            }

            // Let OnDrawGizmos handle rendering when in prefab edit mode.
            // It's not possible to use RuntimeObjects while there.
            if (PrefabUtils.IsPartOfEditingPrefab(gameObject))
            {
                return;
            }

            if (!Cable.RoutePointCurveUpToDate)
            {
                Cable.SynchronizeRoutePointCurve();
            }

            m_segmentSpawner.Begin();
            try {
                var points = Cable.GetRoutePoints();
                for (int i = 1; i < points.Length; ++i)
                {
                    m_segmentSpawner.CreateSegment(points[i - 1], points[i], radius);
                }
            }
            catch (System.Exception e) {
                Debug.LogException(e, this);
            }
            m_segmentSpawner.End();
        }