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 eb1jooz · Apr 24, 2018 at 07:52 AM · performancedllpluginswrapper

DLL calls (Plugins) way slower within Unity

Hello,

I am facing dramatic slow down of my code when using calls to dll form the Plugins folder.

Here is the test I have done:

  • My code is compiled in a bunch of C# and C++ dlls. C++ dlls are native and called within the C# code through specific wrappers.

  • First test I do is outside Unity: in a dedicated C# console project, I call and measure the performance of the C#/C++ dll. It works fine and runs fast as it should.

  • Second test I do is inside Unity. I drop my dlls in the Plugins folder and write an identical test within a MonoBehaviour attached to an empty GameObject in a empty scene. The test runs then about 20 times slower.

I wonder why I see the slow down when using the code though dlls. Is there any different behaviors between direct calls within a dedicated C# project or within Unity ? I did not find any relevant answers so far when Googling the topic.

Thanks for your help!

Comment
Add comment · Show 2
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 eb1jooz · Apr 24, 2018 at 08:35 AM 0
Share

$$anonymous$$y initial test was in the editor. Indeed I get the speeds back when running the test after building the project. I will try it with Unity 2018 to make sure it perform well with this version as well.

Thanks for your quick answer.

avatar image Harinezumi eb1jooz · Apr 24, 2018 at 08:53 AM 0
Share

You are welcome!
I also use some DLLs written in C/C++, and also noticed the performance decrease. Fortunately, it almost completely disappears in builds.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Harinezumi · Apr 24, 2018 at 08:14 AM

Did you do the second test running in the Editor, or did you make a build? The Editor does have a significant overhead, so that could explain the slowdown. Builds are usually a lot faster than running in the Editor. Then again, the reason can be something else as well.
Another possibility is the C#/.Net version: Unity has its custom subset, based on a quite outdated version. Supposedly C# 7 will be supported starting with Unity 2018.1.

Comment
Add comment · Show 1 · 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 TheLazyEngineer · Sep 17, 2020 at 06:20 PM 0
Share

I just did a test where I was getting 3 fps inside the editor using native dll calls. in the build i was getting 140 fps... Using the equivalent c# source code, I was getting 60 fps in editor and in build. Thanks for mentioning this otherwise I would have never tested!!

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

99 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

Related Questions

How do I use two different versions of a .dll in one project 0 Answers

How to link to scripts in the Package Manager when building a dll. 0 Answers

How to use the Windows.Gaming.Input namespace in a windows standalone build? 0 Answers

Unity XR plugin manager Tries to load oculus dll on windows even if its disabled. 0 Answers

How do I get maximum performance on extremely heavy calculations? 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