Problem building WebGL and running it on react-unity-webgl

Reply by saurav0037 | 2024-09-23 11:52:49

convaiClient is available in react now

Reply by erikmendes | 2024-09-23 11:52:58

can i get into trouble because convai web sdk exists in my project?

because I need to have the websdk and also a webgl in the same project, but on different routes…

Reply by saurav0037 | 2024-09-23 11:53:53

I’d suggest using iframe in that case

Reply by saurav0037 | 2024-09-23 11:54:08

or host the unity project differently

Reply by saurav0037 | 2024-09-23 11:56:09

react is a spa so in any case it’ll get messy this way

Reply by saurav0037 | 2024-09-23 11:57:09

Did you try react-unity-webgl package

Replying to saurav0037’s Message

Reply by saurav0037 | 2024-09-23 11:57:09
Did you try react-unity-webgl package

Reply by erikmendes | 2024-09-23 11:57:25

I’m using it

Reply by erikmendes | 2024-09-23 11:57:55

import React from ‘react’;
import { Unity, useUnityContext } from “react-unity-webgl”;

function UnityLoader() {
const { unityProvider, isLoaded, loadingProgression } = useUnityContext({
loaderUrl: “UnityBuild/Build/euvatarwebgl.loader.js”,
dataUrl: “UnityBuild/Build/euvatarwebgl.data”,
frameworkUrl: “UnityBuild/Build/euvatarwebgl.framework.js”,
codeUrl: “UnityBuild/Build/euvatarwebgl.wasm”,
});

return (


{!isLoaded &&

Carregando… {Math.round(loadingProgression * 100)}%

}
<Unity unityProvider={unityProvider} style={{ width: “100%”, height: “600px” }} />

);
}

export default UnityLoader;

Reply by erikmendes | 2024-09-23 11:58:36

import React from ‘react’;
import UnityLoader from ‘…/Loader/UnityLoader’;

function UnityPage() {
return (


EuvatarAI




);
}

export default UnityPage;

Reply by saurav0037 | 2024-09-23 11:59:02

okay i’ll try solving this but this will take some time. Better solution would still be to use iframe

Reply by saurav0037 | 2024-09-23 11:59:26

its spa so if we include scripts in index it’ll be in the entire project

Reply by erikmendes | 2024-09-23 12:01:20

I’ll look for an alternative solution in the meantime…

This conversation happened on the Convai Discord Server, so this post will be closed.