2021.1.1208.2 Color Sensor.



Overview

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.


Where to find

The Color Sensor Physical component can be found under Standard Components > Color Sensor > Color Sensor > Add Physical Component.

It can be accessed from the GameObject menu as well as 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.


Feature layout - Physical Component

Live Data

 

State

Shows whether the Color Sensor is currently active and thus whether it will detect colors.

Output Signal

Shows what color the ColorSensor currently detects. If no color is detected, it will return its Void Color.

Properties

 

Range

The minimum and maximum detection range for the Color Sensor. A gizmo shows a visual indication of how that will translate in the scene.

Void Color

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.

Fixed Rendering

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.

Control Panel

 

Generate Control Panel

Click this button to generate a ControlPanelInterface for the Color Sensor.

Feature Layout - Control Panel

Title

The Title of the Control Panel.

Click to ping the target component in the hierarchy.

Double click to edit.

DCMotor Properties

 

State

Shows whether the Color Sensor is currently active and thus whether it will detect colors.

Output Signal

Shows what color the ColorSensor currently detects. If no color is detected, it will return its Void Color.

Enable/Disable

Enables/Disables the Color Sensor.

Target Component

 

Target Gameobject

The gameobject which has a standardcomponent you want the Control Panel for.

Target Component

The Component which for which a Control Panel is generated.


How to use

  1. Assign a Color Sensor physical component to a GameObject, or create a new one directly from the menu.

  2. Select the desired settings under the Properties tab.

  3. In Play Mode, the color of detected objects will be displayed in the Output Signal field.

Prespective Documentation