load c# script from server

Hi. I want download c# script from URL and load it in my game on runtime.

I know how to use www class to download script and store it in SD card. But how can I load this script to android game?

Thanks so much

I don’t know if what you are asking can actually be done because you don’t have the compiler available at runtime for compiling and interpreting the script. Perhaps it would be better if you looked into including a scripting engine in your project so that you can use scripts instead of C#. That is, unless you intend to write a C# parser for your game.

Perhaps something like MoonSharp: https://www.nuget.org/packages/MoonSharp
Or UniLua: https://github.com/xebecnan/UniLua

UniLua is designed specifically for Unity3D, where MoonSharp is designed for .NET and has proven compatible for Unity3D.

Hi @vahid62,

You can’t do that directly but you might want to look into assetbundles. You can include scripts into assetbundles.

Visit Here:



If you want to include code in your
AssetBundles that can be executed in
your application it needs to be
pre-compiled into an assembly and
loaded using the Mono Reflection class
(Note: Reflection is not available on
platforms that use AOT compilation,
such as iOS). You can create your
assemblies in any normal C# IDE (e.g.
Monodevelop, Visual Studio) or any
text editor using the mono/.net
compilers.Note: Loading scripts from
asset bundles is not supported on
Windows Store Apps and Windows Phone.

Based on your other replies, you might want to look into loading and saving JSON objects that contain the details of all your objects.

By saving a JSON file that basically holds the catalog of your items, their preview pictures, 3d models and whatever else you need, you can then always just load it up in your game and download what you don’t already have.

To be clear, the JSON could look something like this:

    'ID:1': {
      name: 'name',
      picture: 'here',
      model: 'it is here'
        'ID:2': {
      name: 'name',
      picture: 'here',
      model: 'it is here'
        'ID:3': {
      name: 'name',
      picture: 'here2',
      model: 'it is here'
        'ID:4': {
      name: 'name',
      picture: 'here',
      model: 'it is here'

I am talking about JSON because Unity has a nifty new JSON serializer you can use. If you don’t like JSON, you can save your data as XML, flat text, or even in a database. While everyone is perfectly correct in stating that you can’t load C# files without a new build, you sure can download anything else you can get your hands on.

You can’t load a script outside of the project. It needs to be compiled. What are you trying to accomplish, maybe there is a different way to accomplish it than this.