h00tman
h00tman

Reputation: 21

How to include custom library files in Unity build

When I run my Unity app in the editor, it is able to read my .dlls and other custom files the .dlls need and it works fine. However, when I make a build, it only includes the .dll files in the Plugins folder of the build and not the other custom files. Is there a way to force Unity to include the other files as well? I have tried putting them both in the Plugins and Resources folder before building and in both cases it only keeps the .dlls.

Upvotes: 0

Views: 2578

Answers (1)

Programmer
Programmer

Reputation: 125245

The custom files are .obf, but I don't think that's relevant

It is extremely relevant. Unity does not support all type of libraries.

Here are the supported library extensions:

For Windows, you can use .dll.

For Linux, .so is supported.

For Android, you can only use .aar, rar and .so.

For iOS, .a is used but you can also use the non compiled code such as ,.m,.mm,.c and .cpp.

There is no support for .obf. If you want to add it to your project so that you can load and execute it then you are out of luck.

If you just want to make Unity include it to your final project build so that you can read it then you can. This doesn't mean you can load and execute it.

First, rename the extension from ".obf" to ".bytes". Place it in the Resources folder and read it as TextAsset with the Resources.Load function. You can the access the data with TextAsset.bytes.

TextAsset dataAsset = (TextAsset)Resources.Load("YourObfName", typeof(TextAsset));
byte[] data = dataAsset.bytes;

Not sure how helpful just reading it is but this is here to show you how to include it to the build and read it but you can't execute it unless there is a C# API to do so and I don't think that any API of such kind exist.

Upvotes: 2

Related Questions