Search Unity

ClearScript Integration

Discussion in 'Scripting' started by th-reflekt, Nov 7, 2013.

  1. th-reflekt

    th-reflekt

    Joined:
    Nov 4, 2013
    Posts:
    2
    Hello,

    my goal is to execute Javascript code during runtime giving javascript access to my C# scripts. The "ClearScript" library provided by MS supports exactly the functionality i need (http://clearscript.codeplex.com). I downloaded the current version (5.3.9) and put the "ClearScript" folder into the assets. In addition I enabled "unsafe" keyword by creating the "smcs.rsp" and "gmcs.rsp" files containing plain text "-unsafe" into the Assets-folder as well (according to http://forum.unity3d.com/threads/7009-Unsafe-code-in-Unity).

    Still, the compiler is complaining about missing nacespaces (from System):
    error CS0234: The type or namespace name `Dynamic' does not exist in the namespace `System'. Are you missing an assembly reference?

    So my questions:
    • anyone ever tried to integrate the ClearScript library in unity?
    • is it possible to resolve the compiler error (for iOS and Android)?
    • are there any alternatives to ClearScript? (i have to execute Javascript code at runtime AND need some callback functionality which allows the javascript to call a C# function inside of a MonoBehaviour or sth)
     
  2. th-reflekt

    th-reflekt

    Joined:
    Nov 4, 2013
    Posts:
    2
    Maybe anyone knows another Javascript Engine which is usable in Unity?
     
  3. atamocius

    atamocius

    Joined:
    Aug 18, 2012
    Posts:
    8
    Hi there. "System.Dynamic" is only available for the .NET 4.0 framework. The Mono version used by Unity only supports upto the .NET 3.5 framework. So any calls to the "dynamic" keyword will throw an error within Unity.
     
  4. atamocius

    atamocius

    Joined:
    Aug 18, 2012
    Posts:
    8
    You ought to try Jurassic instead. There is a free sample in the Asset Store here on how it works.