Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

Jurassic Interpreter: automatic class generation

Discussion in 'Scripting' started by joshcamas, Mar 27, 2018.

  1. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    1,268
    Hello friends :)

    I am currently using a Javascript engine: https://assetstore.unity.com/packag...javascript-runtime-interpreter-for-unity-2345

    It's extremely easy to create classes and functions! However, it's a bit frustrating since it also requires me to replicate a LOT of code.

    What I'm trying to achieve is sorta like Bethesda's Creation Engine's scripting language, where you can access inventories, characters, ai, and so on.

    Instead of creating a jsCharacter class that allows certain functions and variables to be accessible by Javascript (all of these must be done by hand), would there be a way to create these automatically, perhaps using attributes? Like on a class I want to be accessible to Javascript have an attribute "[JsClass]", then any variables or functions the same way? (And of course any parameters that are in these functions will also need to be supported by

    It doesn't sound too impossible, assuming there is some sort of way to create new classes automatically... Is there??

    One way I imagine is for the editor to literally generate cs files based on attributes, sounds kinda ugly though

    Another issue could be creating a bridge between the js instance and the actual c# character instance


    Any thoughts? This honestly sounds so cool and exciting

    Josh
     
  2. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    1,268
    Looks like I could use T4 Text Templates, does this project sound realistic?
     
  3. lifeisnice

    lifeisnice

    Joined:
    Oct 17, 2018
    Posts:
    1
    Didn't they deprecate JS from Unity? Or is Jurassic a whole diff interpreter.
     
  4. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,378
    Unity's Javascript isn't Javascript. It was called 'UnityScript', though even Unity themselves used the named Javascript and Unityscript interchangeably. It was not true Javascript, but instead was a Javascript like language that compiled into CIL and ran in the mono runtime just like C# is compiled into CIL and ran in the mono runtime.

    And yes, it has since been deprecated because since they've moved to support newer .net standards (4.x), there are features that now exist in C# that Unityscript does not have. Since C# has risen in popularity over the years, instead of upgrading and supporting Unityscript, they just dropped it.

    ...

    As for this...

    It appears to be a javascript interpreter. This is completely different from Unityscript and is a runtime interpreter of the javascript language for running in Unity. The benefits is that because it's a runtime interpreted language, rather than compiled, you can dynamically load and run scripts in game. This can be useful for modding which OP seemed to be interested in doing.
     
    joshcamas likes this.