export unity models without script

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

export unity models without script

Postby blackbird_dream » Wed Oct 25, 2017 10:06 am

Hi Sweenie, Julio,

In VS2017 I changed debug to release and built the solution.
It generated a dll named assembly-csharp.dll
is this dll containing my newtonbody script ?
Can I reuse it in another unity model and how ?
User avatar
blackbird_dream
 
Posts: 354
Joined: Wed Jun 07, 2006 3:08 pm
Location: France

Re: export unity models without script

Postby blackbird_dream » Thu Oct 26, 2017 4:06 am

I guess, I just need to import the dll in a new project and that's the simplest way to export my newton model with protection.
User avatar
blackbird_dream
 
Posts: 354
Joined: Wed Jun 07, 2006 3:08 pm
Location: France

Re: export unity models without script

Postby Sweenie » Thu Oct 26, 2017 5:27 am

It's correct that Unity will compile your scripts into this assembly(managed dll) called assembly-csharp.dll and technically i guess you could include this assembly in another Unity project but I don't think that is the intended way to share your precompiled("protected") scripts with others.

The better way would probably be to create your own managed plugin, the same way we do with Newton Unity plugin.

https://docs.unity3d.com/Manual/UsingDLL.html

Create a new C# DLL project and reference the assembly UnityEngine.dll like we do but also reference our NewtonPlugin. Put your code in there and then add the compiled assembly to a Unity project.
In summary, you will create a managed plugin that is referencing our managed plugin.

This is basically what the Unity Editor does automatically when you create your scripts(from inside the Editor) but the Unity Editor will put all your scripts into the assembly-csharp.dll file and probably some other stuff you may not want.
Sweenie
 
Posts: 498
Joined: Mon Jan 24, 2005 7:59 am
Location: Sweden

Re: export unity models without script

Postby blackbird_dream » Thu Oct 26, 2017 6:45 am

thks for you reply
add the compiled assembly to a Unity project

What do you mean exactly ? Is this :
* open a C# dll template
* add the 2 references (UnityEngine.dll and NewtonPlugin.dll
* write my c# script inside the project
* build it

then
import this build to a new Unity project ?
User avatar
blackbird_dream
 
Posts: 354
Joined: Wed Jun 07, 2006 3:08 pm
Location: France

Re: export unity models without script

Postby Sweenie » Thu Oct 26, 2017 7:31 am

Yep, basically like that.

If for example you name your C# Dll (Class library) BlackBirdPlugin and build it, it will output a dll called BlackBirdPlugin.dll.

Then just add this dll to your Unity project like an ordinary asset.

Basically what this is about is moving the scripts(or rather c# classes inheriting MonoBehaviour) outside of Unity and compiling them yourself. Then instead of having the script code inside the Unity project, Unity uses your precompiled code(the dll).

It's kind of the same as using a precompiled external library in C++ instead of including the full source code, but it's easier with .NET because .NET doesn't need declarations headers, .lib files and stuff.
.NET can read all it needs directly from the dll using reflection, given it's a managed dll. Using a native dll from .NET is way more problematic. That's what we do with Newton and the Swig stuff.
Sweenie
 
Posts: 498
Joined: Mon Jan 24, 2005 7:59 am
Location: Sweden

Re: export unity models without script

Postby blackbird_dream » Thu Oct 26, 2017 8:30 am

thks Sweeine you're kind
User avatar
blackbird_dream
 
Posts: 354
Joined: Wed Jun 07, 2006 3:08 pm
Location: France


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 13 guests

cron