Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Unity scripts to DLL

Discussion in 'General Discussion' started by ofirudwork, Jan 13, 2022.

  1. ofirudwork

    ofirudwork

    Joined:
    Nov 3, 2021
    Posts:
    17
    Hello!
    I want to obfuscate my project - because I want to sell it as a Tool...
    Firstly I need to make these scripts to DLL but when I make it DLL - all my references of MonoBehaviour classes get lost... it's a lot of references and I cannot assign them back...

    How can I transmit my project classes to DLLs without losing references?

    Thank you all!
     
  2. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,754
    You are really better to sell scripts. I don't know if these days anyone sells dlls. Unless absolutely have to. People did that a lot in past. Problem is with dlls, code is unmaintainable, and people won't be able to fix things, once you stop supporting.

    But you can jus create methods, and put into dlls, rather putting game objects into dlls.

    Also, dlls can be decompiled, so anyone really that want to, will be able decipher things.
     
    Last edited: Jan 13, 2022
  3. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,554
    DLLs, created in .NET languages can still get decompiled.

    IIRC scripts implemented as packages would be compiled into dlls, but I might be wrong.

    I wouldn't buy an obfuscated script asset implemented as a dll on unity store.
    Basically, it means I'll be royally screwed once you stop maintaining it, which can happen quickly, depending on circumstances.
     
    zombiegorilla likes this.
  4. tmcdonald

    tmcdonald

    Joined:
    Mar 20, 2016
    Posts:
    160
    People generally aren't buying your assets so they can redo it themselves. If they wanted to do it themselves, they'd just do it. They're buying your assets to save themselves the time and cost of having to do it.
     
  5. ExtraCat

    ExtraCat

    Joined:
    Aug 30, 2019
    Posts:
    52
    Some time ago I bought a nice asset. I don't want to mention its name to avoid needless advertisement, but it really saved me a lot of time.

    There is only one problem: I need it to be able to use HDR colors. It's a really small and easy change in its code that can be done in half a minute. But guess what, if the asset was a dll then I wouldn't be able to do it. And asking the author of the asset to add this feature is pointless, as it wasn't implemented in half a year since I suggested it despite the said author being active.

    So yeah, I'll think twice before buying a dll. No matter how much time they save, too often they need minor tweaks to work properly in a specific game.
     
    Last edited: Jan 13, 2022
    BennyTan and angrypenguin like this.
  6. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,083
    Then fewer people will buy and use that tool.
     
  7. CityGen3D

    CityGen3D

    Joined:
    Nov 23, 2012
    Posts:
    681
    The way to do it is to have a separate project with your library code in, which compiles into DLLs.

    Your Unity project references the DLLs and doesn't have references to the original scripts.

    That way, when you rebuild your DLLs you just copy them over to your Unity project over the top of the old ones (ideally automatically) and your references in Unity wont break.
     
  8. bobisgod234

    bobisgod234

    Joined:
    Nov 15, 2016
    Posts:
    1,042
    I won't buy tools with obfuscated DLL's—it's too risky. I'm screwed If something goes wrong and I need an immediate fix.
     
  9. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,614
    It depends on what's in the DLL, to be honest. If it's Unity-specific code then I'm with the others, it's really risky if we don't have access to provide our own support.

    If you've got stuff that's not Unity specific then having that in a DLL is potentially fine, particularly if the Unity integration code is provided as source. As an example, this is how FMOD is provided. In fact, you are expected to modify the Unity integration to suit your needs. Of course a part of the reason that works for FMOD is that they've been developing and supporting their product for long enough that people are confident they'll still be around. It's somewhat common for Asset Store vendors to disappear at short notice.
     
  10. ippdev

    ippdev

    Joined:
    Feb 7, 2010
    Posts:
    3,850
    Wrong. Maybe the hobbyist but the professional fulfilling a contract will want to customize the product, use what they need and discard the rest. The worst is the product that has it's codebase in a dll and is written by a C# enterprise coder thinking he is doing folks a favor. And then they toss an Interface over the methods so you can't even get a reference to the bloody thing that will stick.
     
  11. tmcdonald

    tmcdonald

    Joined:
    Mar 20, 2016
    Posts:
    160
    You misinterpret. I'm saying that obfuscating to prevent it from being stolen is pointless. People buy code assets so they don't have to implement those solutions (from scratch) themselves. Locking it in a DLL and obfuscating to protect it from the 0.001% of customers who are bad actors is not worth failing to provide the source code for the majority of customers who are good actors and don't care about stealing your code, they're just paying you so they can save themselves time.
     
  12. DragonCoder

    DragonCoder

    Joined:
    Jul 3, 2015
    Posts:
    1,677
    Would say DLLs are only really of use where you leverage the powers of other languages like C++ and thus have no other choice anyways.

    If you really want to, better be truly sure that your API covers all imaginable usecases...