Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Optrix · Jul 31, 2019 at 10:36 PM · scripting problemnamespace

The Issue with 'Func'

I'm having problems with addons defining their own version of 'Func' so that they can use the syntax from later versions of .NET.

The problem is that they don't define func in their own namespaces and instead define them in the application namespace, which means they inevitably conflict.

The package manager itself does this, so for example I can't use several .NET WebSocket classes with Unity without having to erase the package manager from the package cache every single time I start Unity, which gets very old.

Is it possible for Unity projects to override Func in their own namespace and not do so in the package namespace, which should prevent this problem from occurring? Is there any trivial workaround anyone has discovered to resolve this?

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Bunny83 · Jul 31, 2019 at 11:23 PM

I think I don't quite understand the question. Which type do you actually mean? Defined in which assembly? What do you mean by application namespace? Do you mean the "global::" namespace? You can always use an a fully qualified classname to address a certain type. If you actually mean that you have two or more assemblies in your project which define all the same type within the same namespace, yes, that's a problem. Usually you can solve such issues with Assembly aliases, however there's no real support for them in Unity.


However I don't know any type that comes with Unity that is defined in the global namespace. I think the only class I can find is the deprecated "AssetModificationProcessor" which was originally defined in the global namespace but was moved into the proper UnityEditor namespace long time ago.


I'm also not sure what exactly you mean by "Func". Do you talk about the Func delegate types defined in the System namespace? What "addons" are those? Are they official addons or third-party addons? If they are third-party you should direct your complaint towards the developer of those addons.

Comment
Add comment · Show 2 · 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
avatar image Optrix · Jul 31, 2019 at 11:58 PM 0
Share

Yes, I'm referring to the System.Func delegate.

It didn't exist in .NET 2, but rather than defining their own new delegate function, people appear to be defining their own versions of System.Func for use in their code.

"Addins" was not the correct term.

Defining a 'Func' delegate is done in a number of Asset Store assets (Soft$$anonymous$$ask, for example), as well as in the Unity Package $$anonymous$$anager, and also in a number of 3rd party assemblies such as WebSocket4Net. Each does this for .NET 2 compatibility reasons, but when each library re-introduces their own version of System.Func, it causes conflicts and compiler errors.

avatar image Bunny83 Optrix · Aug 01, 2019 at 01:43 AM 0
Share

While it is true that there are many assemblies that come with .NET 2.0 support, they usually have different projects for different target frameworks. Just don't use the .NET 2.0 version. For example WebSocket4Net comes with 2.0, 3.5, 4.0 and 4.5 support. If you load the source code yourself you should build the right assembly. So while the 2.0 project does include the Action.cs file (there's no Func definition in this project that I've found), From version 3.5 onwards the Action.cs file is no longer included


So you most likely use the wrong version. The Unity Package manager does not define the Sytem.Func delegate types as far as I can tell. $$anonymous$$aybe you load some dubious third-party package. I don't have that Soft$$anonymous$$ask asset from the store, however glossing over the content I can't spot a file which looks like it might define their own System.Func types.

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

190 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 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 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 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 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 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 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 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 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 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 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 avatar image avatar image avatar image

Related Questions

How to import project 1 to another project , with same name of script with unique namespaces and different root folder? 1 Answer

The type or namespace name could not be found. Are you missing a using directive or an assembly reference? 4 Answers

Platform dependent flags required in Using/Namespace definition? 1 Answer

Which is the namespace of the Joystick pack?,Which is the nameSpace of Joystick pack? 2 Answers

Removing Namespaces from default scripts ... is it safe ? 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