- Home /
Can't use Namespaces with Mono and 1 class 1 namespace file
Well, For about a month I've been developing a project for the community. Truly smooth sailing for a month... I've had a namespace inside of a Monobehaviour with ONE class. For two days, I've not been able to get the file to work without removing the Monobehaviour from the namespace.
Nothing changed with the name of the class or file. The only thing that changed was I added an IEnum, and a few days AFTER I add it I get this error that the filenames don't match. The class is used as a static reference to call StartCoroutine() in non-Monobehaviour classes, and there were already 4 other Coroutines in the script before this error.
ALSO: I currently have 5< other Monobehaviours in namespaces that aren't flagged and are working.
If I remove the namespace, the file works. If I remove the namespace from 5+ classes though, it's gonna cause unnecessary clutter for the users.
Has anyone encountered a similar problem recently? How do you fix this issue if you are only using One class in One namespace?
EDIT:
I HAVE NO IDEA WHY THIS HAPPENED, but for some reason a Default parameter on a method in the script messed everything up. I HAVE NO IDEA WHY.
IEnumerator AddComponentsToGroup_Coroutine(object Control, List<object> Component, bool add, timeDelayToAdd = 0)
The second I removed the default parameter, it started working...........
I checked, and none of my other Monobehaviour scripts use default parameters.
Are default parameters not supported when using namespaces with monobehaviours? lol
What do you mean "namespace inside of a $$anonymous$$onobehaviour with ONE class"? Can you show code with the namespace and enum declaration?
One thing caught my eye in this post. A monobehavior file has to have the same name as the class it contains.
Yes, will do once I get home from work. The Initial reason why I didn't was because the code is really long... its basically the camel of my system.
Answer by Lairinus · Sep 14, 2013 at 11:32 PM
I just edited my question with the answer....
FOR ANYONE WHO HAS THE SAME PROBLEM- stray far far away from Default Parameters if you wish to do this with a Monobehaviour. If someone can enlighten this situation further I will give them credit and mark it as best, but for right now... Yeah. All I can say is DON'T USE DEFAULT PARAMETERS.
The second I removed the default parameter, everything was working perfectly, as it had been for a month prior.