# Integrating Custom Module with Unity Exporter

**URL:** <https://forum.babylonjs.com/t/integrating-custom-module-with-unity-exporter/46072>\
**Category:** Questions\
**Tags:** unity-exporter\
**Created:** [November 30, 2023, 6:31pm UTC](https://forum.babylonjs.com/t/integrating-custom-module-with-unity-exporter/46072 "2023-11-30T18:31:23Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Guillaume\_Pelletier](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/guillaume_pelletier/32/3695_2.png) [@Guillaume\_Pelletier](https://forum.babylonjs.com/u/Guillaume_Pelletier)\
**Post date:** [November 30, 2023, 6:31pm UTC](https://forum.babylonjs.com/t/integrating-custom-module-with-unity-exporter/46072/1 "2023-11-30T18:31:23Z")

</div>

I’m currently working on a project where I’ve developed a custom module, let’s call it `BLABLA.GUI`, whith custom type extending `BABYLON.GUI`. This module is contained within a file named “blabla.gui.js”. I’m looking to utilize this module in conjunction with the Unity exporter. My main goal is to streamline the process without having to export all of my TypeScript classes or modify the existing code extensively with the

```auto
module XXXX {
...
    const v = new BABYLON.Vector3(0,0,0);
...
}

```

pattern.

Could anyone provide guidance or suggestions on how to effectively integrate BLABLA.GUI with the Unity exporter to achieve this?

according to the documentation

> Native JavaScript Libraries (renamed to .bjs) that are included anywhere in the **Assets** folder will be packaged up and included in your project script file

however when putting the file into a folder in the Assets and trying to reference any of the class into my typescript, this not work

`const c = new BLABLA.GUI.Component(..)`

Failed to find the BLABLA.

Do i need a specific tsconfig setup to generate my module to be compatible ?  
Do i need to provide the d.ts types somehow ?

Thank you in advance for your assistance!

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [November 30, 2023, 8:46pm UTC](https://forum.babylonjs.com/t/integrating-custom-module-with-unity-exporter/46072/2 "2023-11-30T20:46:10Z")

</div>

@mackey the daddy of the exporter might have some ideas

---

<div class="post-metadata">

**Author:** ![Lukas\_Make\_Games](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/lukas_make_games/32/35794_2.png) [@Lukas\_Make\_Games](https://forum.babylonjs.com/u/Lukas_Make_Games)\
**Post date:** [December 3, 2023, 8:53pm UTC](https://forum.babylonjs.com/t/integrating-custom-module-with-unity-exporter/46072/3 "2023-12-03T20:53:52Z")

</div>

I have same question. Any idea?

---

<div class="post-metadata">

**Author:** ![Guillaume\_Pelletier](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/guillaume_pelletier/32/3695_2.png) [@Guillaume\_Pelletier](https://forum.babylonjs.com/u/Guillaume_Pelletier)\
**Post date:** [December 4, 2023, 11:05am UTC](https://forum.babylonjs.com/t/integrating-custom-module-with-unity-exporter/46072/4 "2023-12-04T11:05:49Z")

</div>

Hi all, just following up on my previous query (along with @Lukas_Make_Games ) about the Unity Exporter project extension. Noticed it’s been a few days without a single response, even after @sebavan ping to the creator. I understand it’s not an official Babylonjs tools, but any updates would be greatly appreciated.  
Thanks!

---

<div class="post-metadata">

**Author:** ![Lukas\_Make\_Games](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/lukas_make_games/32/35794_2.png) [@Lukas\_Make\_Games](https://forum.babylonjs.com/u/Lukas_Make_Games)\
**Post date:** [December 4, 2023, 12:16pm UTC](https://forum.babylonjs.com/t/integrating-custom-module-with-unity-exporter/46072/5 "2023-12-04T12:16:08Z")

</div>

Hi, I was trying to integrate external library to the Unity-Exporter and I have to find a workaround. I let you here, in case it’s useful to you:

```auto
//otherScript.js
var MyGlobalVar = function () {
  //...isolated scope
  myVar=otherFunction(){
  //..
  return{
      myVar:myVar
}}

```

then in the PROJECT module, to access the isolated scoped function:

```auto
//scriptComponent.ts
//..
//@ts-ignore
let tempGlobal = MyGlobalVar();

module PROJECT{
   tempGlobal.myVar()
}

```

It would be easier if we could import modules…

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [December 4, 2023, 5:20pm UTC](https://forum.babylonjs.com/t/integrating-custom-module-with-unity-exporter/46072/6 "2023-12-04T17:20:17Z")

</div>

@MackeyK24 was not pinged cause I messed up in his pseudo on the previous message… Now he should be 🙂 but please bear with him as he might be focused on other things or be OOF this week 🙂

---

<div class="post-metadata">

**Author:** ![Pryme8](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/pryme8/32/7212_2.png) [@Pryme8](https://forum.babylonjs.com/u/Pryme8)\
**Post date:** [December 4, 2023, 5:46pm UTC](https://forum.babylonjs.com/t/integrating-custom-module-with-unity-exporter/46072/7 "2023-12-04T17:46:25Z")

</div>

You could have always done your extension under the project module scope.

module PROJECT{  
class BLAHBHElement extends BABYLON.GUI.something{}  
}

---

<div class="post-metadata">

**Author:** ![MackeyK24](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mackeyk24/32/3741_2.png) [@MackeyK24](https://forum.babylonjs.com/u/MackeyK24)\
**Post date:** [December 5, 2023, 9:52am UTC](https://forum.babylonjs.com/t/integrating-custom-module-with-unity-exporter/46072/8 "2023-12-05T09:52:21Z")

</div>

Hey guys… So the babylon toolkit using regular script tags. I dont really like importing modules. If you look at the exported engine.html page that is generated for you. you see all the scripts that get loaded for that project. You can customize a copy of engine.html and save it in the /Assets/[Config] folder and that custom engine.html will get used instead.

But it would be easier to just your custom class to the Unity Project. You can add **.js, .ts and d.ts** files to any folder in the Unity Project.

So you can generate declaration files for your component and add both the script and declaration files to your Unity Projects:

```auto
blabla.gui.js
blabla.gui.d.ts

```

Or you could create your custom gui component in the Unity Project like **MyGuiComponent.ts** like  
@Pryme8 suggested:

```auto
module PROJECT {
    /**
     * Babylon TypeScript File
     * @script MyGuiComponent
     */
    export class MyGuiComponent extends BABYLON.GUI.Container {

    }
}

```

---

<div class="post-metadata">

**Author:** ![Guillaume\_Pelletier](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/guillaume_pelletier/32/3695_2.png) [@Guillaume\_Pelletier](https://forum.babylonjs.com/u/Guillaume_Pelletier)\
**Post date:** [December 5, 2023, 10:18am UTC](https://forum.babylonjs.com/t/integrating-custom-module-with-unity-exporter/46072/9 "2023-12-05T10:18:58Z")

</div>

Hey guys,

Thank you for taking the time to respond. I’ve already using the solutions you suggested. My question was bit different, so i assume importing module on the fly is not possible.  
Thank’s again.

All the best.
