Dependencies, Files and Sub Folders

Your plugin may require dependencies, such as images, fonts, or other various files.

DLL Files
There are two types of DLL files, managed and unmanaged. A managed DLL is the type that can be added as a resource in the .Net project. The unmanaged DLL is a C or C++ library that is used with Interop calls. If you use either of these, you will be aware of which one is being used.

Any managed DLL file that was added as a resource to your project, should be included to be copied as a resource during compile time. Using managed DLL files does not require any path specifications in your code, as the assembly will be loaded when needed. Visual Studio will take care of copying the file, long as it is marked to be copied, during compile, into the root plugin folder. You should not need to worry about managed DLL location, as the visual studio will take care of it, but it must be in the same folder as your Plugin DLL.

The unmanaged DLL usage is a different story. When your plugin references an unmanaged DLL, it also specifies the path. If the path is not specified in the interop declaration, the default directory of your plugin is assumed. The unmanaged DLL must be added to your project as a content type and included to be copied when compiled. This is because unmanaged DLL files are not added as resources in .Net Visual Studio projects, and therefore you must take care of specifying the file to be copied yourself, during compile time. This is easy by simply adding the file to the project as content, and selecting Copy Always from its property settings.


Files & Sub Folders
If your plugin requires reading files from the plugin folder, here's how you can get the path to the plugin root folder, by combing the guid and windows environment settings for the public path. The location of the plugin folder in the Public Documents is defined by the Windows Operating System. The Public Documents and Plugin path is assembled with the method EZ_Builder.Constants.PLUGINS_FOLDER, as seen in code examples below.

This code example combines the user's public ez-builder plugin folder, which comes from the windows environment settings, the guide, and the filename.

Code:


using System.IO;

string OculusRift_Fx_File = ARC.Common.CombinePath(
ARC.Constants.PLUGINS_FOLDER,
_cf._pluginGUID,
"OculusRift.fx");

if (!File.Exists(OculusRift_Fx_File)) {

MessageBox.Show("Unable to find the OculusRift.fx file that should have installed with this plugin. Cancelling");

return;
}


So if you have a fonts subfolder in the plugin folder or some sub in the plugin folder, you can do this...

Code:


string FontFile = ARC.Common.CombinePath(
ARC.Constants.PLUGINS_FOLDER,
_cf._pluginGUID,
"Fonts",
"SomeFont.ttf");


Or to read the files from a subfolder of the plug directory...

Code:


using System.IO;

string fontFolder = ARC.Common.CombinePath(
ARC.Constants.PLUGINS_FOLDER,
_cf._pluginGUID,
"Fonts");

foreach (string fontFile in Directory.GetFiles(fontFolder)) {

Console.WriteLine("File: {0}", fontFile);
}