- Home /
Struggling with unity letting me attach scripts to game objects.
Unity is not letting me attach my scripts to any of my game objects. Whenever it does, it tells me that there is already a definition for it in global.
$$anonymous$$ost likely you're using a class name that's already used in one of the standard namespaces.
Answer by Commoble · Mar 03, 2017 at 06:21 PM
It's hard to tell without seeing your script. but it sounds like Unity is throwing the error when it tries to compile your script, not when you try to attach it to an object.
At the bottom of the Unity window, it shows you the most recent and relevant line from the console log. If this line is red, and it says something like Assets/User/Scripts/Rocket.cs(45,11), then there's an error in that script, and that first number is the line number where the compiler became aware that there was an error (which isn't necessarily where the error is, but in this case it likely will be).
It sounds like you're trying to define a class or variable whose name is already being used by something, so try changing that where the error message tells you the error is. If the problem persists, we'll need to see your script to be able to help you.
Your answer
Follow this Question
Related Questions
Drivable hovercraft 1 Answer
I'm trying to display my ammo; not working 2 Answers
Easily reference class instance 1 Answer
How can I programatically load a .pcx file in my script? 1 Answer
Activate desactivate canvas with c# 1 Answer