[Released] Dynamic C# - Runtime C# Scripting

2952114--218916--Icon.png
Asset Store | Documentation

Dynamic C# allows loading of assemblies and scripts at runtime making it trivial to add modding support to you game by allowing your users to write C# code. In addition, Dynamic C# also allows strict security restrictions to be enforced as specified by the developer meaning that external code can run safely.

Features

  • Compile and run C# scripts at runtime.
  • Fast Execution - once compiled, external scripts run as fast as game scripts
  • Allows for modding support to be easily added
  • Pre-load security checks mean that unsafe code can be identified and discarded
  • Support for loading assemblies and C# scripts
  • All scripts use custom namespaces to prevent clashing type names
  • Support for non-concrete communication using script proxies
  • Simple and clean API for accessing types and proxies
  • Cached member tables for quick reflection
  • Automatic construction of types using the correct method (AddComponent, CreateInstance, new)
  • Comprehensive .chm documentation of the API for quick and easy reference
  • Fully commented C# source code included

Limitations

  • Cannot run under ‘.Net 2.0 Subset’. (Requires '.Net 2.0)
  • AOT platforms such as IOS are not supported
  • Scripts must be compiled before they can be executed

PC, Mac and Linux platforms are supported.

September, 2017: We have now added the Script Evaluator to Dynamic C#. Take a look here for more info!

Need a code editor for your game?
4364407--417205--FeatureTrimmed.png
Check out our other asset asset ‘InGame Code Editor’ which is an advanced text input field with line numbering and fully customizable syntax highlighting for C# and many other languages. Check out the asset store or forum page for more info.

Developer Website | Support

2952114–234034–UserGuide.pdf (1.1 MB)

5 Likes

The review process took longer than expected but I am now pleased to announce that Dynamic C# is available in the asset store.

3 Likes

Version 1.0.3 has been submitted to the asset store for review and should be available in a few days.

  • Added some extra example scripts
  • Fixed a bug in the ‘ScriptProxyExample’ script
  • Fixed a bug when creating instances of non-MonoBehaviour types where the constructor could not be found (MissingMethodException)
  • Fixed errors on import when webplayer is set as the current build target.

Version 1.0.3 is now available in the asset store.

Hello,
Does this support WebGL?
Thanks. :slight_smile:

Hi,
Sorry for the delay.

I did a bit of testing and I was able to build for web gl, however I have not yet been able to compile a script at runtime. The compiler always throws an argument exception about an invalid path even when compiling a script from memory. For now the answer is no but I want to look into this further to see if I can get it working.

Thank you scotty,
I will look forward to purchasing thing this once it works for WebGL.
Compiling script from memory sounds like the best solution.

This project looks very interesting. Does it work with Windows Store apps?

One problem I found with assetbundles is that they do not support loading of scripts at runtime in Windows Store apps. I’m hoping that Dynamic C# can do that.

Unfortunately Window Store cannot be supported because Dynamic C# relies on a few types from ‘System.Reflection’ and ‘System.CodeDom’ which are not available on the platform.

@ZeoGames

After some more testing it looks like we are not going to be able to support WebGL. The exception I mentioned in a previous post was caused by the compiler attempting to access the local file system and this is not allowed in WebGL. At the minute we cannot see any way around this because the compiler requires file system access even when compiling from source files that are already in memory.

Hopefully you can find an alternative solution to achieve your goal.

Thanks for the quick response @scottyboy805 . Would this also be the case for a UWP application? I’m a little confused about the differences between Windows Store apps and UWP.

Yes, same problem for UWP. As far as I am aware, all of the windows app/phone platforms use the same reduced framework so we cant support any of those platforms.

Dynamic C# is now on sale with 30% off.

1 Like

Version 1.0.4 has been submitted to the asset store.

This version fixes an error in 5.6.0 where an ambiguous reference prevents the Dynamic C# source code from compiling. If anyone else is getting this error you can email your invoice number to info@trivialinteractive.co.uk and we will send you the updated package direct so you don’t have to wait for it to be approved by the asset store team.

Hi scottyboy805,

I’m interested in this asset (Dynamic C#), however before buying this asset, i would like to test out the Tank game.
Possible to build it into .exe and share?

Thanks.

I have built a Win32 version of the demo scene for you to try out which you can download from here :slight_smile:

1 Like

Thanks for sharing. :slight_smile:

Hi scottyboy805,

Dynamic C# does looks great for develop education C# coding games. I have a question, will you be planning on making IDE for more user friendly for using Dynamic C#. I mean in future. :slight_smile: I have tried to find is there any asset that will change unity input field into IDE, but no luck.

This is what i found for web uses which is good for IDE however the Dynamic does not support WebGL Ace - The High Performance Code Editor for the Web . Do you have any idea where i can find a useful asset that can do IDE, otherwise i need to make it myself.

We don’t plan on making a UI IDE for Dynamic C# as it would require a lot of work to create a stable and user friendly interface and is not the main focus of Dynamic C#. I also couldn’t find any code editor controls on the asset store but as an alternative perhaps you could use the web IDE you linked inside of Unity via a web browser renderer, something like this maybe that supports java script? I know its a paid asset and quite pricey but maybe there are other similar assets. The only other alternative I can see is to create your own text editor as you mentioned which will certainly be a lot of work.

Hi scottyboy805,

I have purchased this asset. So far so good at the moment. However, i would how to stop script if the user suddenly run an infinity loop? at the moment it will just crash and stop working.

Thanks