{"_id":"@carnegie-mellon-robotics-academy/cra-template-unity-react","_rev":"10-160fd66fea114e39a7a02dd99a4c41d0","name":"@carnegie-mellon-robotics-academy/cra-template-unity-react","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@carnegie-mellon-robotics-academy/cra-template-unity-react","version":"1.0.0","description":"## Installing 1) Install [npx](https://www.npmjs.com/package/npx)  2) Open a terminal and go to a folder where you want to download the template. 3) Enter the command: `npx create-react-app --template @carnegie-mellon-robotics-academy/cra-template-unity-r","main":"template.json","scripts":{"test":"echo \"Error: no test specified\" && exit 1","start":"nodemon server/index.js","build":"webpack --mode production","dev":"webpack --mode development --watch --progress"},"author":"","license":"MIT","dependencies":{"express":"^4.17.1","react":"^16.13.0","react-dom":"^16.13.0"},"devDependencies":{"@babel/core":"^7.8.7","@babel/preset-env":"^7.8.7","@babel/preset-react":"^7.8.3","@babel/polyfill":"^7.10.4","babel-loader":"^8.0.6","css-loader":"^3.4.2","html-webpack-plugin":"^3.2.0","node-sass":"^4.13.1","nodemon":"^2.0.2","sass-loader":"^8.0.2","style-loader":"^1.1.3","webpack":"^4.42.0","webpack-cli":"^3.3.11"},"gitHead":"46184bdf950668af938b6ec8cdb4bb82c8c9d688","_id":"@carnegie-mellon-robotics-academy/cra-template-unity-react@1.0.0","_nodeVersion":"12.16.1","_npmVersion":"6.13.4","dist":{"integrity":"sha512-6dTLLcUJ5EW8uDmSk47Gg/xfxP1uhMYcZEM5e9JPDswkC8zXnW+7VsrjXcDt3culSkXtKTpCNpC49+Y5HOYw4A==","shasum":"f744706be0bda323be5e0c127ce99ff6e1c19048","tarball":"https://registry.npmjs.org/@carnegie-mellon-robotics-academy/cra-template-unity-react/-/cra-template-unity-react-1.0.0.tgz","fileCount":4908,"unpackedSize":286609872,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfLYHhCRA9TVsSAnZWagAA9T8P/3p3lrc27MDWZMhWZy5a\nnka4SZ4tYcoGmLprixpJ0O/eKISKDH4+2NNbGWi+e8ngwSG2pGr50yroDhWR\nK/P5OBPsiNOT2I/sujGSEIXKKA9cqAxm4Vitl6Fonkvjw3Nf1FIY+t8g3Jxu\nYotCJWKiWBGtyTiPxcugTXKUlwGZwJdydGE2WJkQ8ZB6wGWomfiZTHtN6Rcu\nQWAqsrju9SCgaRM+1sAA9qzuifVyqCpZPolAkUIvzh6wZRe1OHLVxd/Zc7yA\nm+bcdDoRH4UBmasK3W851JUFtGY09FHWzw9ClLsMo+EzPZyCN3xS8VlaQFxG\nkIDUvil+MI2zoC3vNcHYNO13KEE2eACAFVeU+BTA0ihdbgr3CKEKT6CuyRdO\n1GwKOBUor184ZBKnDJ5K9VLJq6B0k1IH6FknlrN+f/nHmWS9LDVaOrbOvjc0\nzOFGPyUttoqmGyRqhipjnE4mCU17zoire2cpvlfUxqPZBCxWHxWbPlp7Yhd1\nQC5xdsReJWGFysEyugdS0QiZqsaQ94mC7hUVl881MYxUD8CRHqdiEzUu6LHO\nNQDjDjBE7I+Rr5uK3VN61zhAe/EKdhGQfsUF7heRnCyVqLglF+P4pRBmMOij\nfoL9jNwa2jRuSj43ekj5Rj3ltKqx6FwZpyBMrM/Hu7HuBaAHO4oGBenUCzIq\nuUGq\r\n=iWkV\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCmed0dY0KtdMsuR5UxFIoaJGNE/SPRdm0WuVvf5aYW8wIgLQwxCX2MW8uEZLnuFJPNsXLX1M2eMhIk5hHOozOlVXk="}]},"maintainers":[{"name":"five41","email":"carrozza.developer@gmail.com"},{"name":"bynarlogic","email":"jjarvis@hey.com"},{"name":"cmracademy","email":"vnguyen@nrec.ri.cmu.edu"}],"_npmUser":{"name":"five41","email":"carrozza.developer@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/cra-template-unity-react_1.0.0_1596817886934_0.8075832897940183"},"_hasShrinkwrap":false}},"time":{"created":"2020-08-07T16:31:26.933Z","1.0.0":"2020-08-07T16:31:29.030Z","modified":"2023-11-30T16:23:17.550Z"},"maintainers":[{"email":"ctimperley@cmu.edu","name":"christimperley-cmu"},{"email":"vnguyen@nrec.ri.cmu.edu","name":"cmracademy"},{"email":"carrozza.developer@gmail.com","name":"five41"},{"email":"jbflot@cmu.edu","name":"jbflot"},{"email":"todddurant@gmail.com","name":"tdurant"},{"email":"csobien@andrew.cmu.edu","name":"csobien"}],"description":"## Installing 1) Install [npx](https://www.npmjs.com/package/npx)  2) Open a terminal and go to a folder where you want to download the template. 3) Enter the command: `npx create-react-app --template @carnegie-mellon-robotics-academy/cra-template-unity-r","license":"MIT","readme":"# Unity-React-Template\n\n## Installing\n1) Install [npx](https://www.npmjs.com/package/npx) \n2) Open a terminal and go to a folder where you want to download the template.\n3) Enter the command: `npx create-react-app --template @carnegie-mellon-robotics-academy/cra-template-unity-react`\n\n### Project Environment\nThis template installs a Unity Project along side of a react application. The root of the project is meant to be a workspace for your IDE.\n\n## Getting Started\n### Building Unity\n1) Open My_Unity_Project through Unity3D editor. You may need to upgrade or downgrade, that is fine.\n2) Once open, add TestScene to your build settings.\n3) Click build. Name the game \"unity_game\" and save it in the dist folder.\n### Building the app\n1) cd into the root of the project.\n2) run `npm build` or `yarn build`  (if the build fails try removing node_models and re-install)\n3) Once, complete, run `npm start` or `yarn start`\n\n### Subscribing to messages\nJavaScript\n```javascript\n// When component mounts, listen for any message with a topic of unity_awake\nconst unityAwakeSubscriber = { topic: \"unity_awake\", callback: handleTestMessage }\n\n  useEffect(() => {\n    // addTopicListener imported from unity_api.js\n    addTopicListener(unityAwakeSubscriber);\n  }, [])\n``` \nC#\n```c#\n void Start()\n  {\n    // Find the MessageDispatcher script\n    messageDispatcher = GetComponent<cmra.MessageDispatcher>();\n    // Add an event listener. This subscribes to the topic test, with a method name of startTest which is also a function below.\n    messageDispatcher.addMessageListener(new Subscriber(\"test\", startTest));\n  }\n  private void startTest(object parameters)\n  {\n    // Deserialize the parameters again. TODO: Come up with a solution around having to do this. Simply casting did not work out. \n    StartTestParameters testParams = JsonConvert.DeserializeObject<StartTestParameters>(parameters.ToString());\n    // Pass the parameters to the test coroutine.\n    StartCoroutine(TestCoroutine(testParams));\n\n  }\n```\n\n### Sending Messages\nJavaScript\n```javascript\nconst handleTest = async () => {\n    const msg = { topic: \"test\", message: { method: \"startTest\", parameters: { i_testTime: 3, resolver: \"endTest\" } } }\n    setTesting(true);\n    // Waits until Unity sends a message back with a topic equal to endTest.\n    // This method is imported from unity_api.js\n    await sendUnityMessageAsync(msg, \"endTest\").then((message) => {\n      setTesting(false);\n    });\n  }\n```\nC#\n```c#\n// Sends a message to the browser with a topic of the resolver variable. This message does not need to send an object as parameters. \"messageDispatcher\" is assined on start.\nmessageDispatcher.SendData(null, resolver);\n```","readmeFilename":"README.md"}