유니티 안드로이드 에뮬레이터 - yuniti andeuloideu emyulleiteo

유니티 에디터로도 물론 Ui창 크기를 테스트 해볼 수 있지만, 실제 폰에서 어떤지 궁금할 때가 많다.

실제 서비스하다보면, 일부 폰에서 ui가 깨진다는 소릴 듣곤한다. 하지만 안드스튜디오 처럼, 시뮬레이터나, 애뮬레이터 기능이 없어, 테스트 해보기 애매했었는데, 유니티에 시뮬레이터 기능이 있다는 것을 듣고 사용해 보게 됐다.

1. 패키지 설치

유니티 안드로이드 에뮬레이터 - yuniti andeuloideu emyulleiteo
유니티 안드로이드 에뮬레이터 - yuniti andeuloideu emyulleiteo

 패키지 매니저로 들어가서, Device로 검색해, Device Simulator를 설치하도록 하자.

2. 실행

유니티 안드로이드 에뮬레이터 - yuniti andeuloideu emyulleiteo

설치 후 -> Window -> General -> Deive Simulator가 있을 것이다. 실행하면 아래와 같이 창이 뜬다.

유니티 안드로이드 에뮬레이터 - yuniti andeuloideu emyulleiteo

원하는 기기 종류를 선택해 Play버튼을 누르면, 기존 Game창이 아닌 시뮬레이터 창에서 실행되는 것을 볼 수 있다.

  • 플랫폼
  • Android 스튜디오
  • Google Play
  • Jetpack
  • Kotlin
  • 문서
  • 게임
    • 개요
    • 새로운 기능
    • 가이드
    • 참조
    • 리소스

컬렉션을 사용해 정리하기 내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.

Unity는 Google Play 스토어의 여러 게임에서 사용되는 크로스 플랫폼 게임 엔진입니다. Unity의 모듈식 도구를 사용하면 몰입도가 높은 2D 또는 3D 모바일 게임을 만들어 제공할 수 있습니다.

Android용 Unity 게임을 만드는 단계

Unity를 사용하여 Android에서 플레이어를 위한 게임 환경을 만들려면 다음 단계를 따르세요.

  1. Unity Hub를 다운로드하여 설치합니다.
  2. Unity Hub를 시작합니다. Installs 탭에서 64비트 앱을 지원하는 Unity Editor 버전을 추가합니다. 이 버전은 더 작고 최적화된 다운로드를 지원하는 Android App Bundle을 지원합니다.

    유니티 안드로이드 에뮬레이터 - yuniti andeuloideu emyulleiteo

  3. Unity Editor를 설치하는 동안 옆에 있는 체크박스를 선택하여 Android 빌드 지원 모듈을 포함해야 합니다.

  4. Android 빌드 지원 모듈을 펼칩니다. Unity 2019 이상을 사용하는 경우 Android SDK 및 NDK 도구 모듈을 추가합니다.

    유니티 안드로이드 에뮬레이터 - yuniti andeuloideu emyulleiteo

  5. Projects 탭에서 New를 클릭하여 새 Unity 프로젝트를 시작합니다.

    유니티 안드로이드 에뮬레이터 - yuniti andeuloideu emyulleiteo

  6. 게임을 개발합니다.

  7. 64비트 라이브러리를 출력하도록 빌드 설정을 변경합니다.

Unity용 Google 공식 패키지 다운로드

developers.google.com/unity에서 Unity용 Google 공식 패키지를 다운로드할 수 있습니다.

Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.

Last updated 2022-07-13 UTC.

[{ "type": "thumb-down", "id": "missingTheInformationINeed", "label":"필요한 정보가 없음" },{ "type": "thumb-down", "id": "tooComplicatedTooManySteps", "label":"너무 복잡함/단계 수가 너무 많음" },{ "type": "thumb-down", "id": "outOfDate", "label":"오래됨" },{ "type": "thumb-down", "id": "translationIssue", "label":"번역 문제" },{ "type": "thumb-down", "id": "samplesCodeIssue", "label":"샘플/코드 문제" },{ "type": "thumb-down", "id": "otherDown", "label":"기타" }] [{ "type": "thumb-up", "id": "easyToUnderstand", "label":"이해하기 쉬움" },{ "type": "thumb-up", "id": "solvedMyProblem", "label":"문제가 해결됨" },{ "type": "thumb-up", "id": "otherUp", "label":"기타" }]

민프

[Unity]

[Android][Unity] 안드로이드와 유니티를 연동시켜보자(feat.Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x0)

민프야 2021. 9. 23. 19:37

안드로이드 버튼을 눌렀을때 유니티로 접속이 될 수 있게 연동해보자!!

https://www.youtube.com/watch?v=sf54tOAkmzU&t=301s 

유니티 안드로이드 에뮬레이터 - yuniti andeuloideu emyulleiteo

해당 영상을 참고해서 작성하였습니다.

🎈유니티 - Build Settings - 안드로이드 추가

먼저 유니티에서 안드로이드가 빌드될 수 있도록 

Build Setting을 해주자

유니티 안드로이드 에뮬레이터 - yuniti andeuloideu emyulleiteo

안드로이드 빌드 추가가 되면 
저런식으로 유니티로고가 안드로이드 쪽으로 이동하게 된다.

이렇게 빌드 해주고 
Add Open Scenes를 눌러주면
현재 내가 만든 Scenes들이 추가가 된다.

해당하는 버전에서 
Android Build Support 모듈을 추가해주자!!

유니티 안드로이드 에뮬레이터 - yuniti andeuloideu emyulleiteo

🎈유니티 - Player Settings - Export

유니티를 Export해주기전에

몇몇 세팅값을 변경해주자!

유니티 안드로이드 에뮬레이터 - yuniti andeuloideu emyulleiteo
유니티 안드로이드 에뮬레이터 - yuniti andeuloideu emyulleiteo

이렇게 해주고 Export를 누르면

어느 파일에 저장할 것인지 나올텐데
원하는 공간에 설정하면 된다.

🎈유니티 - unityLibrary 파일 안드로이드 프로젝트 파일에 올리기

유니티 안드로이드 에뮬레이터 - yuniti andeuloideu emyulleiteo

Export된 파일을 들어가면
unityLibrary폴더가 있는데 그걸 복사해서

안드로이드 프로젝트에 넣어주면 된다.

🎈안드로이드- Gradle 설정

Gradle설정은 공식홈페이지에 나와있는대로 해주면된다.

https://forum.unity.com/threads/integration-unity-as-a-library-in-native-android-app-version-2.751712/

Integration Unity as a library in native Android app Version 2

This document explains how to include Unity as a Library into standard Android application through Activity. You can read more about Unity as a...

forum.unity.com

유니티 안드로이드 에뮬레이터 - yuniti andeuloideu emyulleiteo
유니티 안드로이드 에뮬레이터 - yuniti andeuloideu emyulleiteo

* 첫번째 네모 친 칸에서
라이브러리 경로를 잘 넣어줘야한다.

이렇게 해주면 내 프로젝트에 unitiLibrary 폴더가 생성된다.

유니티 안드로이드 에뮬레이터 - yuniti andeuloideu emyulleiteo

🎈안드로이드 - Activity 

MainActivity.xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

UnityHandlerActivity.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    tools:context=".UnityHandlerActivity">

    <Button
        android:id="@+id/buttonClick"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="submit"/>

</LinearLayout>

MainActivity.java

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        startActivity(new Intent(this, UnityHandlerActivity.class));
    }
}

UnityHandlerActivity.java

public class UnityHandlerActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_unity_handler);

        Button buttonClick = findViewById(R.id.buttonClick);

        buttonClick.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(UnityHandlerActivity.this, UnityPlayerActivity.class);
                startActivity(intent);
            }
        });
    }
}

이렇게 해주고 실행시켜주면 Run을 해주면 오류가 발생된다.

🚩 Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x0

이건 
Strings.xml에서

    <string name="game_view_content_description">Game View</string>

넣어주고 실행하면 잘 작동되는 것을 확인할 수 있다.

유니티 안드로이드 에뮬레이터 - yuniti andeuloideu emyulleiteo