Support for assembly definition files


#1

Hello,

Unity 2017.3 added support for assembly definition files, which speeds up compilation times especially for bigger projects by allowing folders to be neatly tied into their own assemblies. The topic about loading types from different assemblies has bubbled up a few times here in the past, but not recently (or in the context of asmdefs).

I thought it would make sense to create an .asmdef for the library, because it shouldn’t require external dependencies (in my setup), but had to find out that custom graphs don’t work anymore because only the current assembly is scanned (AstarData.cs; FindGraphTypes), as I’m met with the error No NavGraph of type 'CustomMapGraph' could be found, 4 graph types are avaliable.

A workaround would be to place extensions to the library in the same folder as the library; but then either importing the package won’t work as nicely as it does now, or I might accidentally overwrite/delete the file with an update.

asmdef files can define excluded platforms, so if the only issue are those odd platforms (.NET Core/Windows Store), putting the code in an #if and trusting the developer to properly set up the asmdef should do the trick.

Sadly, I’m not very knowledgeable on Unity and assemblies, especially when it comes to “odd” platforms such as UWP/Windows Store. I’ve tried a little workaround with System.AppDomain.CurrentDomain.GetAssemblies(), which seems to work somewhat okay-ish. The inspector/editor is still throwing an error because FindGraphTypes might be called before the other assembly is loaded. Still, an official solution or some general guidance would be appreciated!


#2

Right click on the AstarPathfindingProject folder > Create > Assembly Definition does the job for me.


#3

The library does work, but consider the following folder layout/setup:

- AstarPathfindingProject/
 - AstarPathfindingProject.asmdef
 - The whole library
- Scripts/
 - CustomNavGraph.cs
 - Editor/
  - CustomNavGraphEditor.cs

In this case, CustomNavGraph is not available as a graph type, because it isn’t/can’t be loaded, using 4.1.10 of the library and Unity 2017.3, although the latter shouldn’t matter.