Hello,
I have attached the following script to the camera and verified it is starting, but objects in the layers I am trying to hide are still showing when the camera moves far enough away:
using UnityEngine;
using System.Collections;
public class CullAreasByDistance : MonoBehaviour
{
public float DistanceToHideAreas = 5;
void Start()
{
Camera camera = GetComponent<Camera>();
float[] distances = new float[32];
distances[10] = DistanceToHideAreas; //Socket layer (ground)
distances[25] = DistanceToHideAreas; //BuildingAreas layer
camera.layerCullDistances = distances;
}
}
I am using Unity v2019.1.8f1, I can’t see what I am doing wrong?