Cant access to camera propertie,Can't access to camera properties
Hello, i want to modify de cullingMask of my camera. But i cant access cullingMask or any other properties in my camera object. For example, the following code doesnt work :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MapCamera : MonoBehaviour
{
Camera camera;
// Start is called before the first frame update
void Start()
{
camera.cullingMask = 1;
}
}
It says that cullingMask is not defined, it is really strange, this code is typical code from documentation.
Are you sure you haven't a custom class in your project called Camera
? If you are using Visual Studio, left click on the Camera
type and press F12, or right-click + "Go to Definition". If you are redirected to your custom class, you have to declare your camera as follow:
public class $$anonymous$$apCamera : $$anonymous$$onoBehaviour
{
UnityEngine.Camera camera;
// Start is called before the first frame update
void Start()
{
// This will throw an error if you don't declare the camera public
// and drag & drop the camera in the inspector
camera.culling$$anonymous$$ask = 1;
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612195326im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Unity Test Runner --> unable to reference my code from the test 2 Answers
Shader Graph & HDRP time node ineffective 0 Answers
'Button' does not contain a definition for 'Transition' 0 Answers
Cursor does not contain a definition for 'lockState'/'visible' 2 Answers
Visual studio cannot find references to dlls from custom assembly definitions 2 Answers