Skip to main content

Common Issues - Code

This page is dedicated to common issues surrounding code. If you are experiencing an issue that does not relate to code consider looking at one of the other pages in this section, which are also listed here.

Make sure to Update Playable!
A lot of times issues can be fixed by simply updating your plugin to the latest version, please make sure to check you are on the latest release version before looking further into this section. More info on how to do this here

Unable to resolve Luna.Unity namespace#

This could be due to if you are trying to using the Luna API from within another namespace, then the IDE cannot resolve / find the Luna functions.

Possible solution:

  • At the top of the script add the 'using Luna.Unity' directive and remove the 'Luna.Unity' part of any function call. (Example of this below)


Calling a null function; 'is not a function' error shown#

If you are including an external javascript library into a Unity C# script, and not including the null function in the imported class, it will throw a null error.

Possible solution:

  • Make sure that the functions you wish to call from C# are nested within the javascript external class you are importing into Unity. (Example with more information below)

Above you can see that the SDK function is the one being imported into Unity & acts like a class which contains the functions. So all functions used from in Unity needs to be added as nested functions inside the sdk function. send is called from Unity & so has to be included inside the sdk function using the this operator. It cannot be outside the sdk function.

Usage of the Invoke("string", float time) function calls a method using the time as a repeating interval instead of a delay#

This is likely due to a known issue in our engine.

Possible solution:

  • Use a coroutine and the WaitForSeconds function as a workaround.

Input.mousePosition is returning Vector2(0, 0) when not clicking#

This is likely due to a difference between how Unity and Luna handles this behaviour, and/or because of issues that arise when translating from mouse to touch.

Possible solution:

Cannot set property of null error in browser#

This is likely due to naming a class/variable the same as a key namespace in our engine, this can end up causing problems.

Examples of such taken names to avoid:

  • Handle
  • Name
  • Class
  • Transform
  • GameObject
  • Image
  • Map

Possible solution:

  • Change the name of the class/variable name to something different.

Luna not exporting any user scripts, or specific user scripts inside of the project#

This could be happening if you have named the folder that housed the project or scripts 'Editor'.

This is because by default Luna excludes all Editor folders, it just so happens that that includes any folders inside the entire absolute file paths. So if your scripts/project is inside a folder name Editor, your scripts won’t be included.

Possible solution:

  • Don’t name any folders that you don’t want excluded, “Editor”.

Class is already defined JavaScript error#

This could be happening if you have a scriptable object with the same name as another one in your project, or a class with the same name (But different namespace).

Possible solutions:

  • Rename the scriptable object/class so it doesn't have the same name as the other.

Unity.Mathematics / system.Math is not supported in Luna#

We do not currently support Unity.Mathematics or system.Math in Luna. If you are making use of either of these then it will cause issues with your luna build.

Possible solution:

  • Remove the Mathematics / system.Math library and replace with the MathF library. Code can be rewritten using MathF.

Cannot add key to an AnimationCurve using AnimationCurve.AddKey()#

We do not currently support this API in Luna.

Possible solution:

  • When you create an AnimationCurve you can put a parameter with the array of keyframes you need: AnimationCurve heightCurve = new AnimationCurve(keyframes);

Diagnostic panel is empty whilst project is not compiling#

This is likely due to your project including unsupported C# features (7.1 +) in your code.

Possible solution:

  • Please use a different syntax/features. Examples of workarounds for unsupported C# features can be found here.