private void OnDrawGizmosSelected()
        {
            if (!isActiveAndEnabled)
            {
                return;
            }
            // bounds
            Gizmos.color = Color.black;
            MassiveGrassGizmo.DrawBounds(targetTerrain.transform.position, boundsMesh.bounds);

            rendererCollections.TryGetValue(Camera.current, out var grassRenderer);
            var count  = rendererCollections[Camera.current].renderers.Count;
            var colors = Enumerable
                         .Range(0, count)
                         .Select(v => new Color((float)v / count, 1, 1 - (float)v / count))
                         .ToList();

            if (grassRenderer != null)
            {
                int i = 0;
                foreach (var v in rendererCollections[Camera.current].renderers.Values)
                {
                    Gizmos.color = colors[i++];
                    // grid
                    foreach (var gridActiveRect in v.Grid.ActiveRects)
                    {
                        var localPos = gridActiveRect.center - new Vector2(targetTerrain.transform.position.x,
                                                                           targetTerrain.transform.position.z);
                        localPos /= targetTerrain.terrainData.bounds.size.x;
                        var height = targetTerrain.terrainData.GetInterpolatedHeight(localPos.x, localPos.y);
                        MassiveGrassGizmo.DrawRect(gridActiveRect, height);
                    }
                }
            }
        }
Пример #2
0
        private void OnDrawGizmosSelected()
        {
            if (!isActiveAndEnabled)
            {
                return;
            }
            // bounds
            Gizmos.color = Color.black;
            MassiveGrassGizmo.DrawBounds(targetTerrain.transform.position, boundsMesh.bounds);

            renderers.TryGetValue(Camera.current, out var grassRenderer);
            if (grassRenderer != null)
            {
                // grid
                foreach (var gridActiveRect in renderers[Camera.current].Grid.ActiveRects)
                {
                    Gizmos.color = Color.green;
                    var localPos = gridActiveRect.center - new Vector2(targetTerrain.transform.position.x, targetTerrain.transform.position.z);
                    localPos /= targetTerrain.terrainData.bounds.size.x;
                    var height = targetTerrain.terrainData.GetInterpolatedHeight(localPos.x, localPos.y);
                    MassiveGrassGizmo.DrawRect(gridActiveRect, height);
                }
            }
        }