Skip to content

preventing webgl pointer lock #236

Discussion options

You must be logged in to vote

Hi, sorry for my late answer. I've been really busy lately. I hope this answer will still help you and I will add support for locking the pointer in the near future. But for now, there is an easy solution as following:

import React, { useEffect } from "react";
import Unity, { UnityContext } from "react-unity-webgl";

const unityContext = new UnityContext({
  loaderUrl: "build/myunityapp.loader.js",
  dataUrl: "build/myunityapp.data",
  frameworkUrl: "build/myunityapp.framework.js",
  codeUrl: "build/myunityapp.wasm",
});

function App() {
  useEffect(function () {
    unityContext.on("canvas", function (canvas) {
      canvas.requestPointerLock();
    });
  }, []);

  return (
    <Unity u…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jeffreylanters
Comment options

Answer selected by jeffreylanters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants