Converting Unity C# to Babylon JS

As mentioned in the title, I need to covert some C# using Unity to Babylon JS. I’ve googled it, and this works, though not with Unity (Just C#). Since I am looking to transpile a lot of code (this github repo), manually doing it would take a huge amount of time. Is there any other transpilers I could use?

Maybe @MackeyK24 our own Unity GURU would have some tricks ?

1 Like

I do not know of a parser that will convert C# Unity to BabylonJS methods. Pretty sure you will have to do it by hand (as some of the things will be out of scope anyways), or come up with your own parsing method.

For the BJS stuff in unity we still write it all in TS and use no C# other then to attach a component to the entity in the scene for the gltf parser to do its magic and associate it to a TS script.

Basically the only thing that is C# is the param links and object pointers for parsing.

Mackey calls this “auto-magic” :slight_smile:

1 Like

Thanks, is there anything that can just convert C# to JS but ignore undefined classes (e.g. Vector3)?

1 Like

That is beyond my scope of knowledge sorry.

But I would assume yes.

^ this maybe?

But I bet it still going to be a lot of hand work.

Just looking at the project you are looking to convert, and it will take quite a bit of knowledge of shaders, Im also not sure if Sebastian is leveraging geometry shaders or not and if he is then you are pretty much SOL unless you wanna go down a rabbit hole.

2 Likes

As for the JS, do you think SharpKit could work? Also, as for the shaders, I found a couple of good HLSL to GLSL converters (Diligent Engine and this online converter), though unity uses CG, which breaks the converters (even though CG is pretty similar to HLSL). Thankfully, I don’t think I will need to transpile ALL of the code in the mentoned repo, only the code for planet/moon generation, atmospheres, and oceans, which is still a lot though much more manageable.

Thank you @Pryme8 and @sebavan. I’ve been scratching my head with this one, and the code does not seem to complicated. Sebastion goes into enough detail throughout the videos that I believe I can just hand code the shaders and such. Hopefully I spend less than 20 hours on it.

2 Likes

There used to be something called DuoCode

It was a Roslyn cross compiler

I wonder if that is still around

1 Like

Thanks! It does appear to still be working, though it uses VisualStudio, which I don’t have.

Gotta get that VS Code, its honestly one of the better IDE’s you can have.

No, I have VS Code. I mean it is an extension for Visual Studio.

1 Like