Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 Julien-Lynge · Apr 17, 2013 at 05:59 PM · programmingwwwdll

Where does 'extern' point in UnityEngine.dll methods?

I've been poking through UnityEngine.dll with ILSpy. As a bit of background, we're seeing a huge hiccup with some downloads, and the Profiler (Deep Profile) reports the following tree:

 ...
 WWW.get_isDone()
   UnityCrossDomainHelper.GetSecurityPolicy()
 ...

So to try and track down what's actually going on I delved into the UnityEngine dll, but under the definition for the WWW class I see the following:

 namespace UnityEngine
 {
 public sealed class WWW : IDisposable
 {
     ...
     public extern bool isDone
     {
         [WrapperlessIcall]
         [MethodImpl(MethodImplOptions.InternalCall)]
         get;
     }

Since there's no DllImport, how can I determine where exactly this extern is pointing to? Where is isDone actually implemented?

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

Answer by Dracorat · Apr 17, 2013 at 06:08 PM

This means that the function is already implemented in a library internal to the application. It could be in the IL (Mono in this case) or in a DLL that's already imported.

Your question of course flows to "so how do I see the code for it" but unfortunately, you can't with ILSpy. You'd have to disassemble it and read it as assembler language.

Have you asked about the hiccups you're experiencing? Maybe someone has experience with them.

Edit: Link for more info:

http://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.methodimploptions.aspx

Comment
Add comment · Show 6 · 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 Yokimato · Apr 17, 2013 at 06:16 PM 0
Share

Good Answer!

avatar image Julien-Lynge · Apr 17, 2013 at 06:17 PM 0
Share

Thanks, that mostly makes sense. Obviously I have more reading to do :)

As for the particular hiccup, our code is pretty complex (50,000 lines) and we've built things like a download manager that wraps around WWW, so I would need to create a much simpler repro before folks would be of much help. Either there's something we're we've done that's making it look like WWW.isDone is taking a looong time (1150 ms for 47 calls in one case) or there's a Unity issue that's only showing up in our case.

Nonetheless, I'll start another question and link it here.

Thanks again for the help!

avatar image Dreamora · Apr 17, 2013 at 06:30 PM 0
Share

if you do the 47 WWW in parallel such a thing could happen especially when you do not properly interact with it from coroutine. Reason is that each WWW object has an own worker thread in the background, so if you fire too many in parallel you cause some nagging side effects. Especially as they finish the download and load the asset, they will halt the engine (bitmap loading, asset bundle decompress, movie loading and audio loading are all blocking, syncronous calls during which nothing else will take part. 1150ms sounds liek an asset bundle with a detailed mesh for example)

avatar image Julien-Lynge · Apr 17, 2013 at 06:36 PM 0
Share

Here's the full question, hopefully that gives you guys a bit more info. I'll read your comments in a few, but first, lunch :)

http://answers.unity3d.com/questions/440134/long-delay-with-wwwisdone.html

avatar image jzq740176597 · Jul 29, 2016 at 06:28 AM 0
Share

You'd have to disassemble it and read it as assembler language.

Then where the code located ,which dll ? in what language? Do you mean in C/C++? and where the dll ? regards!
avatar image Bunny83 jzq740176597 · Jul 29, 2016 at 09:22 AM 0
Share

$$anonymous$$ost of the "extern" methods in the UnityEngine.dll belongs to native code functions which are implemented originally in C++ and usually reside directly in the player executable. So for a windows build it's simply the ".exe" file. The whole engine is actually written in C++.

Almost all classes in Unity consist of two parts: the managed part that is a .NET $$anonymous$$ono class inside the UnityEngine.dll and the actual C++ class inside the engine's core written in C++ and compiled to native code.

If you open the exe of a build made with Unity in an hex editor / viewer and search for "WWW::get_isDone" you will find it ^^. However that's only the method name inside a string table. To know where the actual code is (in binary) you would have to completely analyze and disassemble the exe.

Actually disassemble native code can be extremely difficult and even if you managed it, it's hard to deter$$anonymous$$e the purpose of the code as it's just assembly. Disassemble the native code is actually forbidden by the EULA AFAI$$anonymous$$. Though you can aquire a source code license from Unity but that costs probably $100k+.

In most cases it's not worth to think about it. A good example is this recent question. First i checked the UnityEngine.dll (ILSpy is always open ^^) just to see it's implemented externally. Then just quickly google for gamma correction and i found that article i've linked. Finally I used Debug.DrawLine to draw the graph of the method (100 sample steps) and draw it next to my own implementation(based on the article) to see if it fits.
It took me about 5 $$anonymous$$utes to figure out what the method does without ever seeing the native code.

There are some method that would be interesting to know how they are implemented, but i can live without knowing. $$anonymous$$aybe some day i come up with a solution myself. Like over here where i kind of "reverse engineered" CalculateFrustumPlanes to come up with an implementation that doesn't allocate a new Plane array each time it's called. The method is buried in a comment below my answer.

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

16 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

Related Questions

Multiple Cars not working 1 Answer

Where can i find the unityengine xml? 0 Answers

Batchmode using a DLL that references UnityEngine.dll and UnityEditor.dll crashes 0 Answers

How to use dll files properly in Unity? 0 Answers

Long delay with WWW.isDone 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