Search Unity

Loading/executing scripts outside of assembly build

Discussion in 'Scripting' started by gibbie_learnersedge, Aug 24, 2016.

  1. gibbie_learnersedge

    gibbie_learnersedge

    Joined:
    Aug 11, 2016
    Posts:
    25
    Hi there.

    I am not sure if this is possible with the current unity.

    Basically what I am trying to do is load/ execute scripts out of the assembly.csharp.dll from the build of apk. Right now all the source code build for android/ios is in assembly.csharp.dll.

    Is it possible to have a seperate dll which only be downloaded when it is needed?
    I wanted to do like "assetbundle" but for scripts.

    I am trying to make a game that basically downloads the files(assetbundle) and scripts(I have no idea how) only when the player have access to a certain stage. So I don't have to build all the source code in one apk.

    I am doing this first is for file optimization and being able to dynamically load different scripts for each level without the need of updating the apk itself.

    So basically when I submit the apk it is like just a main menu with a bunch of "Unlocked" level. Once the level is unlocked, only then it will download the files and scripts.

    The main issue is now I have no idea how do I make the script something like "assetbundles"

    Any ideas please post below. I am in need of desperate help. Basically I am stuck right now.
     
  2. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,187
    You're stuck because it's not possible. At least not in anyway that I am aware of, unless something new has appeared. Scripts in your project can be included with asset bundles as it will use the existing script in the project when you bring them in, but adding a new script that isn't part of the project build isn't currently possible.
     
  3. chubbspet

    chubbspet

    Joined:
    Feb 18, 2010
    Posts:
    1,220
    I have loaded dll's at runtime, but it only worked with unity standalone. If I remember correctly I had to use the CodeDom class to achieve that. Also, this might fall under the dynamic code compilation rules of apple (and I think Android) which is not currently allowed, but I stand to be corrected there.
     
  4. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,187
    Correct, I know apple doesn't allow you to have scripts added outside of the app. If they can't review it or see it when they review the app, they don't allow it. I'm not sure that android has the same policy or not, their time to go up on the store is very small. (I think longest I waited was 2 hours to publish). But it wouldn't surprise me if they had something similar.
     
  5. gibbie_learnersedge

    gibbie_learnersedge

    Joined:
    Aug 11, 2016
    Posts:
    25
    Thanks guys for the reply.
    I mean with the current technology is so advance. I am trying to protect the source code and it seems that it's not possible right now.

    Hopefully in the future Unity will have a feature to do this and apple or android will allow us for dynamic code compilations.
     
  6. chubbspet

    chubbspet

    Joined:
    Feb 18, 2010
    Posts:
    1,220
    I doubt if they will ever allow it as it will be a huge security risk.
     
  7. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,187
    Well, I'll just let you know, chances are unless your game is super popular, chances are nobody is going to go looking at your source code.

    If you have a great game, don't let this hold you back releasing it. Especially if you're just waiting around for apple/android to change how they handle things. The chance that they will is very slim.

    In all honesty, if someone really wants your code, they will find a way to get it. Your best bet is to protect what you can from your every day user and focus on the best game you can make.