Search Issue Tracker

Won't Fix

Votes

1

Found in

2019.4

2019.4.26f1c1

2020.3

2021.1

2021.2

2022.1

Issue ID

1367874

Regression

No

GameObject.GetComponents returns the wrong number of components in "Main Camera" GameObject

RP Workflow

-

Reproduction steps:
1. Open the user's attached "GetComponentTest.zip" project
2. Go to MyMenu > TestItem
3. Observe the output in the Console

Expected result: Console outputs the correct number of components (4)
Actual result: Console outputs the wrong number of components (3)

Reproducible with: 2019.4.30f1, 2020.3.19f1, 2021.1.23f1, 2021.2.0b13, 2022.1.0a10

Notes:
- Only reproduces in the default "Untitled" Scene
- Console outputs the correct number of components after selecting the GameObject from which components are counted ("Main Camera")

  1. Resolution Note (2022.2.X):

    Additional Data are sibling component for Camera, Lights and ReflectionProbe (HDRP only for last one).
    They were designed to handle additional information useful for SRP. There creation is the first time the inspector for the GameObject having those component is displayed. Which is usually the case when you create such a component in your project.

    This issue only happens if you load a scene created without the additional data or if you create it by script.

    There is work in progress change to replace the additional data as a component by something directly in the component (Camera/Light/ReflectionProbe). This change will automatically solve this issue.

    As it is really hard to fix the issue with the current design and the new design will resolve it naturally, we will not fix this issue.

    Note:
    - For migration from Built-In to an SRP, you only need to select your GameObject and save your scene for it to be updated and have the correct amount of component. This is a one time upgrade.
    - If you create your component by script, always add the additional data component along it.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.