{"id":13456878,"url":"https://github.com/fusetools/react-native-unity2","last_synced_at":"2025-03-23T03:12:45.871Z","repository":{"id":42937294,"uuid":"488290462","full_name":"fusetools/react-native-unity2","owner":"fusetools","description":"Embed Unity content in your React Native app!","archived":false,"fork":false,"pushed_at":"2024-09-23T12:43:23.000Z","size":85863,"stargazers_count":37,"open_issues_count":13,"forks_count":7,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-09-23T12:47:31.776Z","etag":null,"topics":["android","ios","react-native","typescript","unity","unity3d"],"latest_commit_sha":null,"homepage":"https://fuse.no","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fusetools.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-05-03T16:49:35.000Z","updated_at":"2024-09-23T12:43:24.000Z","dependencies_parsed_at":"2024-10-25T13:25:10.319Z","dependency_job_id":"d45d3f63-2ae4-40a9-8a67-f3d26963e94f","html_url":"https://github.com/fusetools/react-native-unity2","commit_stats":{"total_commits":40,"total_committers":3,"mean_commits":"13.333333333333334","dds":0.07499999999999996,"last_synced_commit":"4ddf125c2008138c26b8bd3a7c7d473d32cce545"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fusetools%2Freact-native-unity2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fusetools%2Freact-native-unity2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fusetools%2Freact-native-unity2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fusetools%2Freact-native-unity2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fusetools","download_url":"https://codeload.github.com/fusetools/react-native-unity2/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244907396,"owners_count":20529853,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","ios","react-native","typescript","unity","unity3d"],"created_at":"2024-07-31T08:01:29.432Z","updated_at":"2025-03-23T03:12:45.851Z","avatar_url":"https://github.com/fusetools.png","language":"Java","funding_links":[],"categories":["Objective-C"],"sub_categories":[],"readme":"# react-native-unity2\n\n[![NPM package](https://img.shields.io/npm/v/react-native-unity2.svg?style=flat-square)](https://www.npmjs.com/package/react-native-unity2)\n[![NPM downloads](https://img.shields.io/npm/dt/react-native-unity2?style=flat-square)](https://www.npmjs.com/package/react-native-unity2)\n[![License: MIT](https://img.shields.io/github/license/fusetools/react-native-unity2.svg?style=flat-square)](LICENSE)\n\nEmbed Unity content in your React Native app!\n\n* Succesfully tested with Unity 2022.x, 2021.x and 2020.x on Android and iOS.\n\n* Includes a complete, pre-configured [Unity project](unity) and an [example app](example).\n\n* The [example app](example) works on machines without Unity installed.\n\n\u003e This module started out as a fork of [react-native-unity-play](https://github.com/azesmway/react-native-unity-play), but is more or less rewritten with new and improved message passing (C# \u003c=\u003e TypeScript), fixing glitches and stability issues, and adding Swift support. That module was forked from other modules also, so kudos to all creators! 🤩\n\n## Install\n\n```shell\nnpm install react-native-unity2\n```\n\n## Usage\n\n![RNUnity running on Android device](screenshot.jpg)\n\n```javascript\nimport React from \"react\"\nimport {Button, View} from \"react-native\"\nimport {UnityModule, UnityView} from \"react-native-unity2\"\n\nexport default function App() {\n  return (\n    \u003cUnityView\n      style={{flex: 1, justifyContent: \"flex-end\"}}\n      onMessage={onMessage}\n      onReady={onReady}\n      keepAwake={true}\u003e\n      \u003cView\n        style={{\n          flexDirection: \"row\",\n          alignContent: \"space-between\",\n          justifyContent: \"center\",\n        }}\u003e\n        \u003cButton\n          title={\"setColor\"}\n          onPress={async () =\u003e\n            console.log(await cubeApi.setColor(randomColor()))\n          }\n        /\u003e\n        \u003cButton\n          title={\"toggleRotate\"}\n          onPress={async () =\u003e console.log(await cubeApi.toggleRotate())}\n        /\u003e\n        \u003cButton\n          title={\"getAccount\"}\n          onPress={async () =\u003e console.log(await cubeApi.getAccount())}\n        /\u003e\n        \u003cButton\n          title={\"fail\"}\n          onPress={async () =\u003e console.log(await cubeApi.fail())}\n        /\u003e\n      \u003c/View\u003e\n    \u003c/UnityView\u003e\n  )\n}\n\nconst onMessage = (data: any) =\u003e {\n  console.log(\"Unity message: \" + data)\n}\n\nconst onReady = () =\u003e {\n  console.log(\"Ready!\")\n}\n\nconst cubeApi = {\n  setColor(color: string) {\n    return UnityModule.callMethod(\"Cube\", \"setColorRN\", color)\n  },\n\n  toggleRotate() {\n    return UnityModule.callMethod(\"Cube\", \"toggleRotateRN\")\n  },\n\n  getAccount() {\n    return UnityModule.callMethod(\"Cube\", \"getAccountRN\")\n  },\n\n  fail() {\n    return UnityModule.callMethod(\"Cube\", \"failRN\")\n  },\n}\n\nconst randomColor = () =\u003e {\n  return `#${Math.floor(Math.random() * 16777215)\n    .toString(16)\n    .padStart(6, \"0\")}`\n}\n```\n\n## Documentation\n\nSee [getting started](docs/getting-started.md) for information on how to set up your Unity project and React Native app.\n\nSee [Unity artifacts](docs/unity-artifacts.md) for information on how to build your Unity artifacts in Android Studio and Xcode.\n\nSee the included [Unity project](unity) and [React Native app](example) for working examples.\n\nSee these source files for details about message passing in Unity:\n\n  * [`RNBridge`](unity/Assets/RNUnity/RNBridge.cs)\n  * [`RNPromise`](unity/Assets/RNUnity/RNPromise.cs)\n  * [Usage examples](unity/Assets/Example/SpinCube.cs)\n\n## Contributing\n\nPlease [report an issue](https://github.com/fusetools/react-native-unity2/issues) if you encounter a problem, or [open a pull request](https://github.com/fusetools/react-native-unity2/pulls) if you make a patch.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffusetools%2Freact-native-unity2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffusetools%2Freact-native-unity2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffusetools%2Freact-native-unity2/lists"}