본문 바로가기
End/#9 종합 설계

#2 안드로이드(Android)에서 유니티(Unity) 프로젝트 불러오기

by 퍼즐잎 2017. 4. 6.






안드로이드 앱에서 유니티 프로젝트를 불러오기 위해서


먼저 유니티에서 다음과 같은 과정이 필요합니다.






Player Settings에서 Minimum API Level 설정이 가능하고


Build System 에서 ADT 로 설정을 하고 Export를 해야 합니다.





이후에 Android Studio에서 불러올 수 있는 형태로


유니티 프로젝트가 저장이 됩니다.





프로젝트를 불러와서 확인을 해보면


유니티의 여러가지 리소스가 섞여 있어서


필요한 몇가지만 분리해서 


다른 프로젝트로 옮겨서 사용하면 됩니다.


(추후 유니티 프로젝트에서 사용한 리소스에 따라서 방법이 달라질 수 있습니다.)







가장 먼저 해야 할 일은



유니티 프로젝트 안에 라이브러리를


사용할 프로젝트로 가지고 와서 포함하는 작업이 필요합니다.






그리고 그 이후에



UnityPlayerActivity


assetsjniLibs 폴더를 옮겨서 가지고 오면 됩니다.












다음과 같이 옮겨온 이후에 UnityPlayerActivity에 대해서


AndroidManifest.xml에 작성하고 MainActivity에서 Intent를 이용하여 호출하면 


정상적으로 동작하게 됩니다.




1
2
3
4
5
6
7
8
9
10
11
    
...
 <activity android:name=".Unity.UnityPlayerActivity"
            android:screenOrientation="landscape"
            android:launchMode="singleTask"
            android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale|layoutDirection"
            android:process=":unityplayer">
            <category android:name="android.intent.category.LAUNCHER" />
            <category android:name="com.google.intent.category.CARDBOARD" />
    </activity>
  ... 
       
       
cs




android:process=":unityplayer" 


유니티 액티비티에 대해서


프로세스를 따로 할당을 해줘야


호출하는 앱과 동시에 종료가 되는 문제가


해결됩니다.










댓글