본문 바로가기

Flutter

Flutter + Unity(IOS)

0_1 전체 Download

https://github.com/snowballdigital/flutter-unity-view-widget

 

snowballdigital/flutter-unity-view-widget

Embeddable unity game engine view for Flutter. Advance demo here https://github.com/juicycleff/flutter-unity-arkit-demo - snowballdigital/flutter-unity-view-widget

github.com

0_2 Build.cs, XcodePostBuild.cs download

https://github.com/juicycleff/flutter-unity-arkit-demo/tree/master/unity/ARDemoApp/Assets/Editor

 

juicycleff/flutter-unity-arkit-demo

This demo uses flutter unity view widget to show AR KIT with Unity3D - juicycleff/flutter-unity-arkit-demo

github.com

Build.cs
0.00MB
XCodePostBuild.cs
0.01MB

1. Unity Build

Unity로 DemoApp 열기

 

Assets > Editor > Build.cs, XcodePostBuild.cs 0_2 에서 download 받은 파일로 교체
Project Settings 에서 Architecture ARM64 로 변경

 

 Flutter > Export IOS

 

2. pod 설치

Terminal에서 flutter-unity-view-widget > example > ios 이동 후 아래 코드 실행

flutter pub get
pod install

**Flutter 설치시 저장했던 ~/.bash_profile 로 경로 설정 꼭 해줘야함

 

3. UnityUtils.mm 수정

- Runner.xcworkspace를 열고 UnityUtils 검색, 12번째 줄에 코드추가

static bool player_created = false;

- 146번째 줄에 if (UnityIsInited()) { return; } 코드 수정

if (UnityIsInited() || player_created) { return; } player_created = true;

 

4. 기존 UnityProject

flutter-unity-view-widget > example > unity 에 있던 파일들을 모두 삭제하고 그 자리에 기존 UnityProject 이동(Unity Folder 아래에 있던 파일을 모두 지우고 기존 Unity Project 넣기)

Assets > Scripts > Editor 에 Build.cs, XcodePostBuild.cs 추가하고 Project Settings 에서 Architecture ARM64 로 변경 (1. UnityBuild 참조), Flutter > Export IOS (1. UnityBuild 참조), Terminal에서 flutter-unity-view-widget > example > ios 이동 후 아래 코드 실행 (2. pod 설치 참조)

flutter pub get
pod install

 

5. 끝

* Unity Cube를 돌리는 Flutter UI가 보이지 않는 현상이 있다. (Flutter UI가 있는 위치에서 조작하면 동작함) 어떻게 고치지...

'Flutter' 카테고리의 다른 글

Flutter Swiper  (0) 2020.07.21
Flutter 기본 Widget 구현  (0) 2020.07.17
Flutter 기본예제  (0) 2020.07.15
Flutter + ARFoundation 기본세팅 (Windows)  (0) 2020.06.19
Flutter 설치 (MAC)  (0) 2020.06.18