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 TharosTheDragon · Oct 03, 2017 at 02:03 AM · framework

Why are only certain .NET libraries available in Unity?

When I try to use System.Drawing I get this error:

 Assets/Scripts/TileCanvas.cs(3,14): error CS0234: The type or namespace name `Drawing' does not exist in the namespace `System'. Are you missing `System.Drawing' assembly reference?

I am most certainly not missing the System.Drawing assembly reference. Moreover, when I look at the list of all references there's nothing to distinguish System.Drawing from any of the namespaces that work just fine. So how am I supposed to tell the difference between references that work and references that don't before I see the error message?

I don't actually need help getting rid of the error message because I found that answer here: http://answers.unity3d.com/questions/53170/using-drawing-package-like-systemdrawing.html . But my question still stands about why Unity works this way.

Also, System.Drawing.Size has a SerializableAttribute. So why can't I set its properties in the inspector?

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
2

Answer by Bunny83 · Oct 03, 2017 at 02:24 AM

Unity doesn't use the .NET framework but an old version of Mono. The only exception is the WindowPhone build target which actually uses .NET. Of course Unity does not include all the standard libraries since they all would need to be shipped with your game.

Unity is not a .NET or Mono application. Unity is written in C++. It just uses Mono / .NET as scripting environment.

Manually adding references to assemblies in MonoDevelop or VisualStudio is pointless. Unity doesn't use the ".csproj" file at all. It only creates this file so the code editors get all the information they need. Unity compiles the actual assemblies directly with the shipped Mono compiler.

If you actually need an assembly which is not part of the core, you have to copy it into your assets folder of your project. Keep in mind that you may need to copy also other assemblies where the imported assembly depends on. Also note that some assemblies of the .NET framework can't be included into Unity as they may depend on OS specific implementations (like Windows Forms).

ps: If you had searched first you should have found tons of similar questions like this, or this, or this

Comment
Add comment · Show 3 · 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 Bunny83 · Oct 03, 2017 at 02:32 AM 1
Share

ps: It's true that the Size struct inside the System.Drawing namespace is marked as Serializable, however it doesn't have any fields that can be serialized. The struct has only private fields which aren't serialized by Unity. Properties are never serialized by Unity's serializer.

avatar image TharosTheDragon · Oct 03, 2017 at 01:23 PM 0
Share

Thank you, that's very informative. And yes, I did find those similar questions. There's just one more thing I'm trying to get answered. If Unity doesn't use .NET then why are some namespaces available like System.Collections? And as I was asking before, is there any way to tell the difference between the namespaces that are available and the namespaces that aren't?

avatar image Hellium TharosTheDragon · Oct 03, 2017 at 01:31 PM 2
Share

Because $$anonymous$$ono is an open-source implementation of the .Net framework, so you will be able to use namespaces such as System.Collections. I don't know where to find the "available" namespaces though.

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

71 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

Related Questions

How do you organize your own "framework" code? 1 Answer

Using a .embeddedframework (ios) in Unity - EntryPointNotFoundException 0 Answers

Create a framework bundle for Standalone build 0 Answers

objective-c method call from unity 1 Answer

Getting a Build error for Windows Phone 8 Platform, It's working fine in PC 0 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