Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Lairinus · Sep 14, 2013 at 03:04 PM · c#monobehaviournamespace

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

Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Jamora · Sep 14, 2013 at 03:19 PM 2
Share

What do you mean "namespace inside of a $$anonymous$$onobehaviour with ONE class"? Can you show code with the namespace and enum declaration?

avatar image AndyMartin458 · Sep 14, 2013 at 04:40 PM 0
Share

One thing caught my eye in this post. A monobehavior file has to have the same name as the class it contains.

avatar image Lairinus · Sep 14, 2013 at 09:29 PM 0
Share

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.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

17 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

How to use MonoBehaviours inside namespaces. 3 Answers

How do c# scripts get accessed by the Unity Engine 2 Answers

You are trying to create a MonoBehaviour using the new keyword. This is not allowed 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges