The question is answered, right answer was accepted
Namespace inside DLL file
Hi guys,
I want to ask, if its possible to create DLL file from .cs file, which uses some namespaces from other script like:
using SomeNamespace // not Unity
namespace MyNamespace {
public static class MyClass {
//Some Scripts here where I use SomeNamespace
}
}
And then, create DLL file from my .cs file. Because Im trying to do something like this, but always I get error: The type or namespace name could not be found. Are you missing an assembly reference?
For creating DLL Im using Unity docs way:
-r:/Applications/Unity/Unity.app/Contents/Managed/UnityEngine.dll -target:library path-to-cs-file
Thank you very much
Can you be more clear on what you are asking because it sounds like you are asking:
"Can I use namespaces to do what namespaces are for?"
Im trying to create plugin, where Im using other free scripts from different people, which are needed for my plugin. Im accessing these scripts via namespaces, because its easy way. But when Im trying to convert my .cs file into DLL file, I get error above. If I know better way to prevent other people from modifying my own scripts, I would do that, but I dont know
What do you mean convert your cs into a dll? You mean building right?
Namespaces dont build to individual dlls by default. you need to create a new code library project in your IDE and the output of that project when you build will be a dll.
You then need to reference that in your main project either directly as a file, or as a folder or as a package.
yes this is the way Im using in my plugin, but when I convert it into DLL file, I got error
heh no no :) dont bother brother :) you explained it to me very well. So if I want to "lock" my files from modifying them and reading them, so users cant see my source code, because its locked somehow, how can I achieve this? because DLL file can do that, but as I can see, its not ideal for my project
I mean, its plugin, so it will be in unity asset store, where you can download it (or pay :D ), but I want to somehow lock/hide/whatever my source code
You have to create a new class library project, build it into the assets folder, then build a package then deploy to the assets store.
Even if its compiled to a dll people can still decompile it you know?
So no. C# DLLs cant really do that.