The Color Sensor is a component that can be used to detect colors directly in front of it within a certain range.
A Color Sensor detecting colors of the objects in its field of view
The Color Sensor Physical and Logic components can be found under Standard Components > Color Sensor > Color Sensor.
It can also accessed from the GameObject menu or from the Hierarchy Context menu.
A new GameObject will be created if you do not have a GameObject selected. Otherwise, the Color Sensor will be added to the selected GameObject
Shows whether the Color Sensor is currently active and thus whether it will detect colors
Shows what color the ColorSensor currently detects. If no color is detected, it will return its Void Color
The minimum and maximum detection range for the Color Sensor. A gizmo shows a visual indication of how that will translate in the scene
The default color that will be returned when no colors are detected
On Value Changed
A UnityEvent that is fired as soon as the Output Signal of the Color Sensor changes. Other scripts can subscribe to this event to be notified of the change
The function forces the color sensor to detect colors on fixed intervals which will prevent it from possibly missing frames
WARNING: This function is very resource heavy
Generate Control Panel for ColorSensor
Click this button to generate a ControlPanelInterface for the Color Sensor.
The Phyisical Color Sensor component attached to this Logic component.
In the PLC I/O panel you can see the latest input and output values from the PLC.
These settings are general Logic Component settings. Look at the Logic Component Documentation for more details.
Assign a Color Sensor physical component to a GameObject, or create a new one directly from the menu
Select the desired settings under the Properties tab
In Play Mode, the color of detected objects will be displayed in the Output Signal field
NOTE: The Output Signal of the sensor is the perceived color by the sensor. Keep in mind that the scene lighting is of great influence on the measured value.