UnityToolkit Query String For Playground

Yo @sebavan and @Deltakosh

So I am making a new version of the Babylon Toolkit For Unity (For Upcoming Version 7 Release)

This version has been architected as a library first runtime library your load into your project. It is No Longer dependent on the actual Unity Exporter. You can do everything the Babylon Toolkit was doing in Unity Game Design environment right in your own project or even right in the playground. This includes all the interactivity you get from using the Babylon Toolkit Script Component system.

So now the Unity Export is more of an Interactive Content Creation Tool you use to make the UnityGLTF files that can be loaded into babylon.js (when the babylon.toolkit.js is loaded)

Delta added support for the Babylon Toolkit Unity Export Runtime to be loaded on the playground so we can load the Interactive UnityGLTF files that the Unity Exporter produces

Can we please add the feature when you save a playground and the Unity Toolkit was loaded, please prefix the ?UnityToolkit query string to the resulted url so it would look like this


instead of


That way, the person clicking the generated url link for the play ground does not have to have Load Unity Toolkit checked and i dont have to manually prefix every playground url that you save with ?UnityToolkit if using the UnityGLTF content on the playground.

Pretty Please… That would make the workflow for sharing UnityGLTF content on the playground so much smoother.

@RaananW … Can you take a look at this feature request … Please :slight_smile:


the playgrond is configured to load the Unity toolkit, if it is referenced in the code. why is that not enough?

It would be smoother if I didn’t have to manually append ?UnityToolkit to saved playground urls

But if no can, no can

Sorry! I probably misunderstood something. I thought this is how you want to do it.

In general, what we do with different dependencies is check if they are referenced in the code, and then load it (this is what we do in the playground). Havok is an example - if HavokPlugin exists in the code it will download the dependency, otherwise it won’t. This can be the mechanism that the unity toolkit is referenced - if it is referenced in the code, download the dependency. otherwise don’t.

I will be happy to help with that, if it makes sense.

Yo @RaananW

Dude I would love for you to help me with making it easier for other to load interactive unity content via a gltf.

With that being said, my new architecture (babylon.toolkit.js) which has all the Unity Toolkit classes also has the UnityGLTF parsers. One of the features of the new architecture is an GLTF extension I wrote to add self loading scripts like how gltf loads the textures reference in the gltf json.

So now for playground to use completely interactive unity gltf is, ALL IN THE GLTF. So at minimum you can have an entire experience run from just the act of loading a unity exported
gltf using whatever you want to load.

So a playground could load unity exported content with one like of code, for example

await BABYLON.SceneLoader.ImportMeshesAsync(null, folder, "unityexported.gltf")

There may not be a reference to ANY of the Unity Toolkit classes that you could OPTIONALLY have in your playground code, like:


My aim is to be able to work with exported interactive unity content just like any other GLTF.

Now the new architecture is completely standalone and independent from actual Unity Exporter Editor. In your application you would load the toolkit either using a traditional script tag:

<script type="text/javascript" src="babylon.toolkit.js">

Or using npm:

npm install babylon-toolkit

And can be loaded at runtime like so:

await BABYLON.Tools.LoadScriptAsync("babylon.toolkit.js");

For the playground, currently when using ?UnityToolkit or selecting Load Unity Toolkit from the playground settings, we are using the playground this._loadScriptAsync to load
the runtime for use. If you can think of a smoother way to achieve this, I would really appreciate
your help.

For Example, Unity has a package called Unity Starter Assets. Is has a player armature and a physics enable prototyping environment

Here is how the new Babylon Toolkit For Unity can work in the playground as well as your own applications (including npm i babylon-toolkit support) for your node based applications.

Here is what the new Unity Toolkit will look like (Without the workaround block of code, once we get the loadScriptAsync issue fixed)

Example Unity Toolkit Playground:

Note: Enable the physics debug view to see all the ZERO CODE OUT-OF-THE-BOX physics that is configured on the entire scene

1 Like

@RaananW … Please check out my new Babylon Toolkit For Unity architecture. Any suggestions on making that a smooth experience for developers to use Unity Exported Content on the playground without a bunch of extra crap

Yo @Pryme8 … this new Babylon Toolkit architecture was inspired by your desire to work with regular playgrounds to do fast prototyping without the longer build process of typescript compilation and scene export of the Unity Exporter. Now you can literally do anything the older Unity Exporter Editor can do right in the playground
using code (Except the scene editing features of course) .

Oh yeah @Pryme8 I totally got Havok Physics integrated as well as a Raycast Vehicle System and working on a Kinematic Character Controller

Pinging @sebavan @Deltakosh @Cedric @carolhmj

Checkout unity content in playground:

1 Like

I see. There is no init or any function that is called to populate the needed loaders or classes?

Would adding a comment (something like “// This code is using the Unity Exporter”) be acceptable? This way we can automate the entire process.

If you can share a few playground (i saw the one you already did :slight_smile: ) i could make sure it works with all of them.

Yo @RaananW … I added a playground init function


Or the shorthand alias


Can you add support to detect those functions.

And what, would that replace the ?UnityToolkit query string detection ?

The Load Unity Toolkit would still remain of course, we just get rid of the url detection and replace with init code detection, right ?

If this function is present in the code, it will automatically load the unity toolkit. I don’t mind checking for other keywords as well, but this is perfect - exactly what I expected :slight_smile:

Add the code inspection to enable unity toolkit by RaananW · Pull Request #14760 · BabylonJS/Babylon.js (github.com)

1 Like

Sweet… Thanks @RaananW

NICE… I think that should work pretty good :slight_smile:

1 Like