Search Issue Tracker
Fixed in 2018.1.X
Votes
1
Found in
2018.1.0a5
2018.1.0b13
Issue ID
1025374
Regression
Yes
[2018.1] 'Can't add script behaviour VisualContainerAsset' error when adding script to GO with mismatched file and class name
Reproduction steps:
1. Create a new script.
2. Change the filename of that script.
3. Add script to an object in the scene.
Expected error message: "Can't add script component 'NewBehaviourScript' because the script class cannot be found. Make sure that there are no compile errors and that the file name and class name match."
Actual error message: "Can't add script behaviour VisualContainerAsset. The script needs to derive from MonoBehaviour!"
Reproduced: 2018.1.0a5, 2018.1.0f1
Not reproducible: 2017.1.3p1, 2017.2.1p3, 2017.3.1f1, 2018.1.0a4, 2018.2.0b1
Comments (24)
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Tile Palette grid is moved after entering Play Mode
- Tile Palette Edit mode turns off in Play Mode
- The Editor crashes when Generating Font Atlas in the Font Asset Creator with “9999999999” padding and 256x256 Atlas Resolution
- [iOS] An “ArgumentNullException” error is thrown when GetIntroductoryPriceDictionary() method is called
- Font Import Settings documentation page is missing when the documentation button is pressed in the Inspector window
Jack-3rd
Aug 16, 2018 15:25
Just got this error, have created scripts with Visual Studio fine with not issue. But started a new project and got the error
DillanAcc
Jul 08, 2018 08:28
This hasn't been resolved yet
CyRaid
Jun 10, 2018 09:13
Definitely should be a different error message like "Class Name must be the same as the script filename".
Destructor83
May 28, 2018 19:39
I've already understood why this happened with me. In my case file name of script was different with class name for one letter. I fix mistake and all work good
Destructor83
May 28, 2018 19:35
Yes I have this problem with Unity 2018.1.0f2
Ricky2442
May 22, 2018 11:49
with Unity 2018.1.0f2
Ricky2442
May 22, 2018 11:48
I'm getting this error with a newly created scripts.
SAAARGE
May 05, 2018 14:45
I'm getting this error message on scripts that definitely derive from MonoBehavior that were working fine before the update. Here's an example of one of my scripts that is doing this that clearly shouldn't be:
public class HUDController : MonoBehaviour
{
public static HUDController Instance { get; private set; }
public GameObject healthIconPrefab;
public static Timer timer;
public Button gunButton;
public Button meleeButton;
public Text timerText;
public Text scoreText;
public Text coinText;
public RectTransform ammoCounter;
public HorizontalLayoutGroup healthLayoutGroup;
public Slider staminaSlider;
[HideInInspector] public Animator animator;
private static GameObject[] bulletIcons;
private static GameObject[] healthIcons;
private void Awake()
{
if (Instance == null)
Instance = this;
else
Destroy(gameObject);
DontDestroyOnLoad(this);
animator = GetComponent<Animator>();
timer = ScriptableObject.CreateInstance<Timer>();
}
}