Search Issue Tracker

By Design

Votes

0

Found in

2022.2.12f1

2023.1.0b10

2023.2.0a8

Issue ID

UUM-31850

Regression

Yes

Script Component is treated as an Editor script when attaching to GameObject and when there are two partial classes with the same name and file name in the project

--

-

Reproduction steps:
1. Open the attached "repro_IN-36142WrongMessage.zip" project
2. Open the "Assets/Scenes/SampleScene" Scene
3. In the Hierarchy window, select the "TestObject" GameObject
4. In the Project window, drag and drop the "Assets/FirstPartClass" script to the Inspector window
5. Observe the error message

Expected result: The error message shows "Can't add script component 'FirstPartClass' because the script class cannot be found..."
Actual result: The error message shows "The script is an editor script."

Reproducible with: 2022.2.9f1, 2022.2.13f1, 2023.1.0b10, 2023.2.0a8
Not reproducible with: 2022.2.8f1
Could not test with: 2020.2.46f1, 2021.3.22f1 (There is no error message)

Reproduced on: Windows 10

  1. Resolution Note:

    This is an improvement, as we need to know what *.cs file a given class is coming from. This is because that file will act as the one dependencies will be setup on, ie. for attaching to gameobjects, serialization ect.
    Before the behavior could be inconsistent because it would depend on order, now we highlight the issue with a error and can consistently get the same file for a class.

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.