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 Penj · Jan 19, 2017 at 12:11 AM · c#unity 5.net-assembliescross-platform

Unity/C# Cross-platform games & Libraries

Hello,

I was wondering if someone could help me with a fairly thorough answer to the following:

If I'm making a Unity game, and I want it to be Cross-platform compatible, (e.g. Windows/Mac/Linux), can I use "using statements" to import additional C# libraries, while maintaining cross-platform compatibility?

For instance, I recently imported a very common .NET library, (using System.Collections.Generic;), for very basic use. However, this library is not directly supported by Unity right off the bat. (Where it has to be resolved and added in with a "using statement".)

Now, I now it works for Windows just fine, because am a .NET shop.

But... I guess I'm not sure how "Mono" and the .Net libraries interact. To my understanding, Mono is what allows .NET to work cross-platform.

So is Unity setup to only allow certain .NET libraries?
Or can/does Mono convert any libraries? (including external DLLs?)

I know you can't download .NET for MAC/Linux, so do extended libraries "break" cross-platform? Are they included in a Unity build to make it run?

Thanks, Benji

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

3 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by Eric5h5 · Jan 19, 2017 at 05:46 AM

You're using some terminology incorrectly, and not quite understanding how Unity or .NET works. "Using" statements do not import libraries, they merely import a namespace. All that does is save you having to type out the entire thing every time, e.g. var foo = new List<int>(); rather than var foo = new System.Collections.Generic.List<int>();. However the compiled code is 100% identical either way. It's simply there for convenience, nothing else. So, this statement is entirely incorrect:

For instance, I recently imported a very common .NET library, (using System.Collections.Generic;), for very basic use. However, this library is not directly supported by Unity right off the bat. (Where it has to be resolved and added in with a "using statement".)

You didn't import a library when doing that, and Unity does support it right off the bat. It's part of .NET core and you can't avoid having it available in Unity. It's not relevant as far as cross-platform concerns go.

Unity on Windows uses Mono, same as other platforms, so almost everything is automatically cross-platform. One exception is Windows Store apps, which are different from normal Windows apps, and actually use "real" .NET, not Mono. However the Windows Store version of .NET is missing some functionality that's in Mono (oddly enough, considering how old Unity's version of Mono is), so there might be some difficulty porting to that platform, depending on which functions you use exactly. However the "porting" process in this case does not involve libraries or anything, but simply trying to find alternative functions that are common to the Windows Store .NET and Unity's Mono.

Porting when using native code libraries is another matter, however nothing in your question is about such a thing, so you can ignore that.

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

Answer by Arkaid · Jan 19, 2017 at 12:28 AM

Unity can be compiled in Mono 2.0 subset (default) and Mono 2.0... though I think the subset is gone in Unity 5.5

The subset is the most broad one, that is supported pretty much in every platform (windows, mac, linux, android, ios, etc). Mono 2.0 has more classes, but the support is a bit more restrained.

These libraries are packed with your project so they work no matter which platform you're running it on.

Here's the full compatibility list of which classes work where

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

Answer by MCudlitz · Jan 19, 2017 at 01:11 AM

It depends entirely on what dependencies you are using, and which .net features those dependencies are in turn using. Unity runs on a fairly old version of mono, so some features might not be implemented. Additionally, you may have problems with certain frameworks as packaging them with your game might not even be legal. With that being said, if you import only libraries that you have the license to, that use only Mono 2.0 features, they should work. DLLs are different, and you will have to make platform-specific fixes for this. For Android, you can use https://developer.android.com/ndk/index.html, which allows you to make native plugins, letting you use DLLs. I'm not sure how it works on the iphone, but what I do know is that it's not fun at all.

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

10 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

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

How to get a GameObject to follow an instantiated object then when a new one spawns follow the new Instantiated object 1 Answer

C# boids separation help 0 Answers

How do I make my Player move? 1 Answer


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