<picture>
<img alt="react-native-godot" src="https://raw.githubusercontent.com/calico-games/react-native-godot/HEAD/static/banner.png" />
</picture>
<br />
React Native Godot
Godot을 React Native 🔮으로 가져오세요. React Native 내에서 몰입감 있는 3D 경험이나 인터랙티브 게임을 직접 만드세요.
npm version
godot engine
Expo SDK
목차
<a id="screenshots"></a>스크린샷 📸
<img src="https://raw.githubusercontent.com/calico-games/react-native-godot/HEAD/screenshots/screenshot1.jpeg" alt="Multiple Cubes demo" align="center" width="150" hspace="2" vspace="10">
<img src="https://raw.githubusercontent.com/calico-games/react-native-godot/HEAD/screenshots/screenshot2.jpeg" alt="Earth demo" align="center" width="150" hspace="2" vspace="10">
<a id="features"></a>기능 🚀
- 🏎️ 네이티브 C++ JSI 성능 - 직접적인 JavaScript와 네이티브 바인딩
- 🔥 GPU 가속 렌더링 - Metal(iOS) 및 OpenGL/Vulkan 지원
- ✅ 완벽한 React Native 호환성 - 구형 및 신규 아키텍처 모두 지원
- 🎮 완전한 Godot 통합 - 모든 Godot 변종과 기능에 접근
- 🧙♂️ 런타임 GDScript 컴파일 - 스크립트를 동적으로 생성하고 실행
- 📦 쉬운 프로젝트 가져오기 - Godot 프로젝트를 RN으로 가져오는 간단한 워크플로우
- 🔄 양방향 통신 - React Native ↔ Godot 메시징
<a id="device-support"></a>장치 지원 📱
iOS 지원은 구현되었으며, 전체 Android 지원은 곧 제공될 예정입니다.
| Platform | Supported |
|---|
| iOS Device | ✅ |
| ... | |
<a id="requirements"></a>요구 사항 🥸
<a id="installation"></a>설치 🚀
npm install react-native-godot
yarn add react-native-godot
<a id="quick-start"></a>빠른 시작 👇
1. GodotProvider 설정
GodotProvider로 앱을 감싸서 Godot를 올바르게 초기화합니다:
import React from 'react';
import { GodotProvider } from 'react-native-godot';
...
2. 게임 컴포넌트 생성
import React, { useEffect, useState } from 'react';
import { GodotView, useGodot, useGodotRef } from 'react-native-godot';
...
<a id="api-reference"></a>API 참조
<a id="godot-view"></a>GodotView 컴포넌트
React Native에서 Godot 씬을 임베딩하기 위한 주요 컴포넌트입니다. 여러 개의 GodotView 컴포넌트를 같은 화면에 사용할 수 있으며, 각각은 다른 씬을 렌더링하지만 동일한 Godot 엔진 인스턴스를 공유합니다.
Props
| Prop | Type | Description |
|---|
source | `string | ImageSourcePropType` |
| ... | | |
Instance Methods (via ref)
| Method | 설명 |
|---|
getRoot(): Node | 로드된 씬의 루트 노드를 가져옵니다. |
| ... | |
정적 메서드 (Static Methods)
| Method | 설명 |
|---|
GodotView.startDrawing(): void | Godot 렌더링 엔진을 시작합니다 (앱당 한 번 호출). |
GodotView.stopDrawing(): void | Godot 렌더링 엔진을 중지합니다. |
단일 GodotView 예제:
const MyGame = () => {
const godotRef = useGodotRef();
...
다중 GodotView 예제:
const MultiSceneApp = () => {
const gameRef = useGodotRef();
const uiRef = useGodotRef();
...
💡 참고 사항 (Note): 모든 GodotView 인스턴스는 동일한 Godot 엔진을 공유하므로, 여러 뷰를 가지고 있더라도 앱당 한 번만 GodotView.startDrawing()을 호출하면 됩니다. 어떤 씬이 활발하게 렌더링되고 있는지 제어하려면 개별 뷰 인스턴스에 대해 pause()와 resume()을 사용하세요.
예제: 개별 씬 제어:
minimapRef.current?.pause();
...
<a id="godot-variants"></a>Godot 변형 타입 (Variants) 🍭
모든 Godot 변형 타입은 전체 메서드 및 속성 지원과 함께 사용 가능합니다:
사용 가능한 타입:
AABB | Basis | Color | Plane | Projection | Quaternion | Rect2 | Rect2i | Transform2D | Transform3D | Vector2 | Vector2i | Vector3 | Vector3i | Vector4 | Vector4i
사용법 (Usage):
const { Vector3, Color, Transform3D } = useGodot();
...
완벽한 문서: Godot 변형 타입
<a id="runtime-gdscript-node-creation"></a>런타임 GDScript 및 노드 생성 🧙♂️
GDScript를 런타임에 생성하고 컴파일한 다음, 동적으로 생성된 노드에 연결합니다:
const { Script, Node } = useGodot();
...
Script API (스크립트 API)
| Method | 설명 |
|---|
Script() | 새로운 빈 스크립트를 생성합니다. |
setSourceCode(source: string): boolean | GDScript 소스 코드를 설정하고 컴파일합니다. |
Node API (노드 API)
| Method | Description |
|---|
Node() | 새 빈 노드 생성 |
| ... | |
💡 팁: 더 나은 TypeScript 사용성을 위해, node.call("methodName", args) 대신 (node as any).methodName(args)를 사용하여 스크립트 메서드를 직접 호출할 수 있습니다. | |
<a id="scene-node-access"></a>장면 노드 접근 🎯
로드된 Godot 장면의 노드에 접근하고 상호 작용합니다:
effect(() => {
if (!isGodotReady || !godotRef.current) return;
...
<a id="react-native-godot-communication"></a>React Native ↔ Godot 통신 📡
React Native → Godot
React Native에서 Godot 스크립트로 메시지 전송:
godotRef.current?.emitMessage({
type: 'player_action',
...
Godot → React Native
Godot 스크립트에서 React Native로 메시지 수신:
<GodotView
onMessage={(instance, message) => {
console.log('Received from Godot:', message);
...
Godot 스크립트 구현
extends Node
@onready var rn_singleton = Engine.get_singleton("ReactNative")
...
<a id="project-setup"></a>프로젝트 설정
<a id="importing-godot-projects"></a>Godot 프로젝트 가져오기 📥
기존 Godot 프로젝트를 React Native에서 사용하려면:
- 내보내기 프리셋 구성 추가
Godot 프로젝트 디렉터리에 export_presets.cfg 파일을 생성합니다:
[preset.0]
name="main"
...
- PCK 파일 생성
제공된 스크립트를 실행합니다 (OS에 맞게 경로 수정):
./gen-pck PROJECT_FOLDER_PATH
- React Native 프로젝트에 추가
생성된 .pck 파일을 React Native의 assets 폴더로 이동합니다.
- iOS에서 project.godot 포함
project.godot 파일을 Xcode 프로젝트 번들에 추가합니다.
<a id="metro-configuration"></a>Metro 설정 🚇
metro.config.js에 PCK 파일 지원을 추가합니다:
const config = getDefaultConfig(__dirname);
...
<a id="limitations-known-issues"></a>제한 사항 및 알려진 문제 🚧
텍스처 임포트 설정
텍스처나 3D 모델을 가져올 때, VRAM Compressed 형식을 사용하지 않도록 주의하세요. 이 형식은 PCK 파일에 제대로 내보내지지 않을 수 있습니다.
<img src="https://raw.githubusercontent.com/calico-games/react-native-godot/HEAD/screenshots/screenshot3.png" alt="VRAM Compressed" align="center" width="200" hspace="2" vspace="10">
PCK 에셋 스와핑
현재 런타임에 PCK 에셋을 교체할 수 없습니다. 새로운 PCK 파일을 로드하려면 앱을 다시 시작해야 합니다. 이는 저희가 조사 중인 Godot 엔진의 제한 사항으로 보입니다.
플랫폼 지원
- iOS 시뮬레이터는 아키텍처 차이로 인해 지원되지 않습니다.
- Android 지원은 개발 중입니다.
<a id="contributing"></a>기여하기 🤝
여러분의 기여를 환영합니다! 핵심 개발은 비공개 저장소에서 이루어지지만, 기여하고 싶으시다면 다음을 따라주세요:
- 아이디어를 논의하기 위해 이슈(issue)를 생성하세요.
- 비공개 저장소 접근 권한이 필요하면
[email protected]로 문의해 주세요.
- Godot Engine, C++, React Native 경험이 선호됩니다.
- Bazel 지식이 있으면 도움이 됩니다.
<a id="license"></a>라이선스 👨⚖️
MIT 라이선스입니다. 자세한 내용은 LICENSE를 참조하세요.
<a id="credits"></a>크레딧 🙏