setFullScreen not working in case of React hooks
See original GitHub issueHi,
I am trying to use this library with react hooks. I am able to load the content and all events are also working. But somehow setFullscreen method is not working. With pre hook version of react this method is working. below is sample code that i am using. Please note that progress event is working properly here.
export default function App() {
let unityContent = new UnityContent( “Build/Build.json”, “Build/UnityLoader.js” ); const [progression, setProgression] = useState(0);
unityContent.on(“progress”, progressionVal => { setProgression(progressionVal * 100); });
const onFullScreen = () => { unityContent.setFullscreen(true); };
return (
<div> <Unity unityContent={unityContent} /> <button id="fullScreenButton" onClick={onFullScreen}></button> </div>
);
Issue Analytics
- State:
- Created 4 years ago
- Comments:6
Top GitHub Comments
Thanks AdhamMoussa,
Creating a top component without any hooks and initialize unityContent from there solved the problem.
Many many thanks AdhamMoussa for pointing out the solution! Really thankful!
@AdhamMoussa you are correct! That solved my issues and I believe also for #74. Really greatful for the assistance.