Cannot find name 'BABYLON'.ts(2304) Unity exporter vs code

I’m trying to use the Unity Exporter ’
Babylon Editor Toolkit - Classic Edition 4.0.3
’ and I’m running into some issues with the namespace BABYLON when trying to reference my Typescript.

I’ve looked around and couldn’t find anything, would anyone know a solution to this issue?

@MackeyK24 do you know what the issue is here?

Are you using VSCode… That seems like a typescript cant find the .d.ts files (babylon.d.ts and babylon.manager.d.ts)

Try get latest VS Code… Also BUILD the whole project ONCE to create tsconfig.json in the root project folder… The tsconfig.json SHOULD allow the .d.ts files to be ANYWHERE in the /Assets/** folder… I think they are in the babylon template library folder now.

Thanks so much for the response, I did find the tsconfig in my \Assets\Toolkit\UnityExporter-master\Manager I just un rared it to it’s own folder:

{
"compilerOptions": {
    "target": "ES5",
    "module": "system",
    "lib": ["es5", "es2015", "dom"],
    "experimentalDecorators": true
},
"include": [
    "types/**/*",
    "src/**/*"
] 
}

Is that okay?

And when you say rebuild do you mean from Unity?

I believe @MackeyK24 means to build the Babylon.JS project so that the .d.ts files are generated.

Awesome, I’ll give that a try.

@MackeyK24 @Drigax
After trying to build it ctr+ shift + b I’m getting a ton of errors:

Assets/Toolkit/UnityExporter-master/Manager/src/babylon-system.ts:577:63 - error TS2694: Namespace 'BABYLON' has no exported member 'Animation'.

577         public static FastMatrixInterpolate(animation:BABYLON.Animation, currentFrame: number, loopMode:number, result:BABYLON.Matrix):void {

So should I just roll back to another version or am I doing something wrong?

No… Not that tsconfig from the latest repo… That is for my new Scene Manager API which is not ready yet.

When you build project in the Unity Exporter… It will generate a tsconfig.json (each time you build)… Its gets its info from the templates/config.json (or something like that)

Note: The Build Project in the Unity Exporter… Does ALOT MORE than just trying to build Directly Frmo VSCode… Is That What Are doing… Trying to build from VSCode…

Try look at the Getting Started Video… I think it goes into the BUILD and PREVIEW options :slight_smile:

Yeah, I assumed so @MackeyK24 But still I’m unable to reference the namespace after I build with Either the Unity plugin Build and Preview:


or through tsc (And I get a ton of errors trying to build this way) but I still can’t get teh BABYLON namespace either way:

and after I build and run: image

And I have a tsconfig.json generated in my Assets/toolkit/... folder:

The tsconfig.json contains this:

{
    "compilerOptions": {
        "target": "ES5",
        "module": "system",
        "lib": ["es5", "es2015", "dom"],
        "experimentalDecorators": true
    },
    "include": [
        "types/**/*",
        "src/**/*"
    ] 
}

and I’m using this package:
image

I also just tried to create a new project and preview it and just made a simple ts and C# file and I’m getting the same error:

OK… I see your problem… First Off… That manager that is in the REPO is my new GLTF based Scene Manager API… Will not work in Classic Edition Exporter.

The Classic Edition tsconfig.json looks like this (and is generated every build):

{
    "compilerOptions": {
        "experimentalDecorators": true,
        "target": "ES5",
        "module": "system",
        "allowJs" : false,
        "declaration": true,
        "inlineSources": false,
        "inlineSourceMap": false,
        "outFile": "/Users/Mackey/Documents/Unity/Babylon Legacy Playground/Export/debug/BabylonPlayground.js"
    },
    "include": [
        "assets/**/*"
    ]    
}

You dont have to manually put tsconfig.json in your project folder… the build will handle that using the config template (/Assets/Babylon/Templates/Config/options.json)

Second… It looks like you took the WHOLE repo and imported into your project.

YOU ONLY NEED TO DRAG THE Babylon Editor Toolkit.unitypackage from the the redist folder into your clean Unity Project.

You should have a folder layout like this (/Assets/Babylon is Main Toolkit Folder):

The Getting Started Video goes into all this… How to setup and add a script component… I think… I will review the video as well :slight_smile:

Yep… Its all in the video… about the Unity Package you need to install in your project… Check that out :slight_smile:

Note: You do not copy the whole UnityExporter-Master… You just need to install the native unity package for the toolkit: Babylon Editor Toolkit.unitypackage that is in the REDIST folder

Also… Update your TypeScript:

npm install -g typescript

I am using 3.5.2 right now :slight_smile:

Hey @MackeyK24 the previouse images were of me importing the redistribute to a empty folder but I tried importing it again, building but I’m still not getting the namespace reference:


To generate those files I did this

and my type script is updated as well:
image

This is on a brand new project with the \UnityExporter-master\Redist\Babylon Editor Toolkit.unitypackage imported into the scene, UnityExporter/Redist at master · BabylonJS/UnityExporter · GitHub

I also don’t see it generating a tsconfig file anywhere in the project when I hit Build and Preview so is there something I’m doing wrong here? :disappointed_relieved:

Package up that whole project in a Unity Package and send it too me…

BTW… The tsconfig.json should be generated in root Unity Project Folder… NOT IN ASSETS OR EXPORT… But in the same folder level as Assets

Also… FOLD OUT your Script Compilation Options on the Scene Exporter Panel… Maybe you dont even have the Script Compiler Stuff Setup

Take a screen shot with the script options so i can see what you got :slight_smile:

Note: the video at 11:30 minutes in shows the Typescript Setup Options… Just enable typescript and detect your tsc compiler locations… Please watch whole video :slight_smile:

1 Like

After rebuilding it and restarting it started working, it must have been some dependencies, thank you so much Mackey, and thank you so much for the tool!

1 Like

Sweet

3 Likes