- Home /
Removing Namespaces from default scripts ... is it safe ?
Hi all,
I am not an expert in scripting and the Unity structure is still a bit obscure to me. I am currently trying to check for events I created in my game from inside the FirstPersonController script that comes with Unity.
I think that due to the class being part of its own namespace it can't detect events which I created in my other scripts.
Is it safe to remove that namespace so that I can access my events in the FirstPersonController class ?
Answer by beStrange · Mar 28, 2017 at 01:23 PM
The main use for namespace is to prevent naming conflicts and,as already mentioned, to organise things. Removing namespaces from a tightly packed system, like it is the case for Unity, will most likely result in a ton of issues across the board.
TL;DR: No it's not safe to remove namespaces from default scripts.
In your case, there are probably some underlying issues in the way you trigger and subscribe to your own events. Creating and using a custom event system might be a little to much for you at the moment and you might be better of using the callbacks that are provided by Unity.
Answer by NicholasSheehan · Mar 23, 2017 at 02:44 PM
Yes, Namespaces are used to organise code.
I had a look around and it looks like the FirstPersonController namespace is required in other scripts from the standard assets so I think if I remove the namespace from it those scripts won't work
do not remove namespace's from scripts that come with unity unless you actually know exactly what you're doing. the reason for that is that every script that references the suddenly removed namespace item will be lost, and you'll have to go through every one, and redirect them.
if you want to use those existing scripts, you add a
using whatever.TheName.Space.Is;
reference at the top of your script, and then you can use it.