Author Topic: System.dll required in NGUI trial  (Read 6729 times)

RelayOne

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
System.dll required in NGUI trial
« on: July 08, 2013, 09:40:50 AM »
I downloaded the trial version of NGUI, and built a test scene. I noticed that System.dll was included in the iOS build. Have you tried to remove system.dll dependency from NGUI in the purchase version?

System.dll adds just over a megabyte in the distribution of a game, and it can usually be avoided without too much effort. Do you use LinkedList in NGUI?


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: System.dll required in NGUI trial
« Reply #1 on: July 08, 2013, 12:28:21 PM »
Search for "using System;"

It's used in quite a few places.

RelayOne

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: System.dll required in NGUI trial
« Reply #2 on: July 09, 2013, 12:28:07 AM »
Unfortunately, it's not that simple. Many functions exposed by "using System;" only require mscorlib.dll.

Take for example this head-scratcher: "System.Collections.Generic.List<T> only requires mscorlib.dll, but System.Collections.Generic.LinkedList<T> requires System.dll. I found this out by analyzing Assembly-CSharp.dll using a program on windows called ".Net Reflector".

I wish that Unity or MonoDevelop would tell you why it's including .dll files, but unfortunately it appears to keep the details hidden -- regardless if the reason is just to include some ridiculously small feature of System[.*]*.


RelayOne

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: System.dll required in NGUI trial
« Reply #3 on: July 09, 2013, 12:58:39 AM »
I just did a slight bit more digging and made some progress. It turns out that you can turn off the "System" reference in MonoDevelop to help identify places that need System.dll. You can do so by going into Monodevelop's "Project->Edit References...", and turning off the System package under the "All" tab. (Don't remove System.Core, as that has the essentials from mscorlib.dll").

There was only one reference to a System.dll in UIPanel.cs on line 10:
// using System.Collections.Specialized;

I commented it out, and it compiled without error. So, I concluded that your included .cs files do not actually reference System. I verified this by opening Assembly-CSharp.dll in the assembly browser and verified that "References" did not include System.

However, after a bit more digging, I opened up NGUI.dll in the assembly browser in MonoDevelop, and saw that the assembly references "System" in addition to "mscorlib". This is shown by expanding the "References" section under "NGUI.dll" in the left pane of the assembly browser. That tells me that only you can address this problem.

Would you be willing to crack open your source .cs files that produce your NGUI.dll and try to identify and remove System.dll references using the first trick I mentioned? It's likely that your use of one or more of the generic collections is causing the problem.

Your advertised "lightweight for mobile" will be much more compelling if you can reduce the size of the resulting game by over 1 MB by removing reference to System.dll, as recommended by the Unity doc here: http://docs.unity3d.com/Documentation/Manual/ReducingFilesize.html.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: System.dll required in NGUI trial
« Reply #4 on: July 09, 2013, 08:24:39 AM »
NGUI doesn't have a DLL. Only the (very old) free version hides some code in a DLL.

RelayOne

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: System.dll required in NGUI trial
« Reply #5 on: July 09, 2013, 09:35:11 AM »
That's encouraging to know that NGUI is available to peruse as code in the paid version. I haven't yet committed to buying because of this issue. Do you have an estimate about how much work it would be to remove dependency on System.dll given what I found?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: System.dll required in NGUI trial
« Reply #6 on: July 09, 2013, 10:17:52 PM »
Can't say as I don't know what else is using system.dll, but if you succeed in cleaning them out without sacrificing functionality, I'll certainly be willing to integrate your changes into the main repository..

RelayOne

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: System.dll required in NGUI trial
« Reply #7 on: July 10, 2013, 01:16:52 AM »
This was EASY. The problem was only in UIPanel.cs. You had already addressed this issue for Flash. Simply remove the #if/#endif around #define USE_SIMPLE_DICTIONARY, and your code no longer depends on System.dll. It looks like upgrading to Unity 4.1 has a similar effect, but I didn't test that.