- Home /
How do I not use a script?
Whenever I add a script to Unity, it automatically tries to use it, even if it is not attached to an object.
Let's say I want to test something, and I do not want to destroy a movement script I have on my Hero. I Duplicate that script, and give it a name like ... moveOld, so I have a backup. Then I start working on the script that is attached to the Hero. BUT... It now gives me errors saying:
The namespace global::' already contains a definition for
PlayerMovement'
So it's reading a script that is not attached to anything. It's just in a folder. I tried moving it to different folders, but the only way I get rid of the error is to DELETE it.
So... How do I test a new script without killing the old one? I do not want to have to create new version of my game, it takes up too much memory.
Please help.
Answer by Patel-Sagar · Aug 21, 2014 at 05:15 AM
whenever you duplicate the script, you give it name like 'moveOld' but you did not change class name into that script. that's why it is giving you error. You have to change the class name inside the script to 'moveOld'. then it will work as your backup.
did you get it? else let me know.
Answer by fishZombie · Aug 21, 2014 at 06:45 AM
public class PlayerMovement*OLD* : MonoBehaviour
Got it. thanks. It would be nice is we could just right click on a file, and say ACTIVE, or NON-ACTIVE.
I was getting all these errors on Assets, now I know one of the reasons why.