Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 Afterbrain · Nov 20, 2019 at 10:44 AM · .netlibrarydrawing

System.Drawing or equivalent.,Getting System.Drawing to work in unity - or alternative library.

I need to draw a curve passing through a set a points. System.Drawing has the perfect function for it, Graphics.DrawCurve(), however, I cannot get it to work.

  • System.Drawing.Common.dll compiles with .Net standard 2.0, but does not seem to be supported. Error: PlatformNotSupportedException: System.Drawing is not supported on this platform.

  • With other version of the .dll/ .NET the compiler cannot find System.Drawing.Graphics.

Anyone has any idea if it is possible to get this to work (and explanation as to why not, if that is the case would also be greatly appreciated)? Or if there is any other library with a similar function? I found several options for drawing Bezier curves, but I cannot find anything that will fit a curve to a list of points the way DrawCurve does.

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
Best Answer

Answer by Bunny83 · Nov 20, 2019 at 03:44 PM

Well first of all it should be noted that the Graphics class in the System.Drawing namespace just capsulates a GDI+ rendering surface which is a Windows / Microsoft proprietary interface. Since Unity uses Mono or the IL2CPP compiler it's quite difficult to actually get it working. The classical System.Drawing.dll requires the actual .NET framework and a windows system. Mono does have it's own System.Drawing implementation however it still just capsulates the GDI+ native objects of the windows API.


Using System.Drawing, even when building for windows PCs only, would be a complete overkill. This assembly (and all dependencies) are huge. Also you would actually create a native windows object (like a bitmap or DIP image) where you would need to extract the pixel information, convert it into something Unity can use and create an actual Texture2D in Unity. Of course it's probably possible with some native code plugin magic to somehow transfer the data on a lower level. Though this is way too complicated to draw a curve.


As you can read in the documenation of DrawCurve it just draws a cardinal CatmullRom spline. The default tension is set to 0.5 unless you use an overload and specify a different one. If you don't want to work through the interpolation of such a spline yourself, the Centripetal Catmull-Rom spline wikipedia article has a rudimentary implementation. This implementation is not really well made since it should just show an example. I haven't really used the following things nor checked their quality. However I think they should provide you some code examples and snippets to get started:


https://www.habrador.com/tutorials/interpolation/1-catmull-rom-splines/
http://wiki.unity3d.com/index.php/Hermite_Spline_Controller
https://en.wikibooks.org/wiki/Cg_Programming/Unity/Hermite_Curves
https://assetstore.unity.com/detail/tools/modeling/splinemesh-104989(related forum post)


Some paid assets my google search found:
https://assetstore.unity.com/detail/tools/animation/aurora-spline-9953
https://assetstore.unity.com/detail/tools/utilities/dreamteck-splines-61926

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 · Nov 20, 2019 at 03:45 PM 0
Share

ps: you haven't mentioned what platform(s) you actually want to target.

avatar image Afterbrain · Nov 22, 2019 at 03:18 PM 0
Share

Thank you so much! That is exactly what I wanted to know. With the Wikipedia article I should be able to get my own implementation. (platform was just windows, but agreed, Graphics looks like an overkill.)

avatar image corriedotdev · Nov 23, 2020 at 09:46 PM 0
Share

I dislike this answer. It offers alternatives due to "bad design" over the op's query regarding getting system.drawing working. Regardless if he got it working fine, ill continue trawling as this solution wont work for me.

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

117 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

Related Questions

Including Google Apis to Unity .Net and C# 0 Answers

Speech Recognition Unity Pro 2 Answers

How to create a library from my C# project that runs on Android 1 Answer

Getting SSH.NET to work in Unity 1 Answer

The classes in the module cannot be loaded? 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