Unity-Technologies / uaal-example

Other
733 stars 233 forks source link

[UUM-20370] Update the project to use both Activity and GameActivity #87

Closed VeryHappyYoung closed 1 year ago

VeryHappyYoung commented 1 year ago

Purpose of this PR

Jira link: https://jira.unity3d.com/browse/UUM-20370 Trunk PR: #32061

\ The issue:

  1. Before introducing GameActivity for Android in 2023.1, the way you get FrameLayout was updated first.

    In 2022.2, UnityPlayer extends FrameLayout.

    Screenshot 2023-06-08 at 18 32 44

    As of version 2023.1.0a17 UnityPlayer doesn't extend FrameLayout. Instead, it provides getFrameLayout() API.

    Screenshot 2023-06-08 at 18 33 52 Screenshot 2023-06-08 at 18 38 11
  2. After introducing GameActivity for Android in 2023.1.0a20, Unity project exported using GameActivity entry point fails with the error below: 

    C:\Projects\uaal-example-master\UnityProject\androidBuild\unityLibrary\src\main\java\com\company\product\OverrideUnityActivity.java:5: error: cannot find symbol
    import com.unity3d.player.UnityPlayerActivity;
                             ^
      symbol:   class UnityPlayerActivity
      location: package com.unity3d.player

\ \ Solution: Use mUnityPlayer.getFrameLayout() instead of mUnityPlayer. And, to make the project work for both UnityPlayerActivity and UnityPlayerGameActivity, updated Unity source code(#32061)

Now we have three options when you export the example to an Android Project like below. ( Go to Player Settings window -> In Other Settings -> Configuration section -> select Activity or GameActivity, or both as Application Entry Point)

  1. Export the project with both Activity and GameActivity options selected. Screenshot 2023-07-17 at 14 50 46 Screenshot 2023-07-17 at 14 58 12

\

  1. After exporting the project with only Activity option checked, users must delete the MainUnityGameActivity from the NativeAndroidApp project. Screenshot 2023-07-17 at 14 51 23 Screenshot 2023-07-17 at 14 44 07

\

  1. After exporting the project with only GameActivity option checked, users must delete the MainUnityActivity from the NativeAndroidApp project. Screenshot 2023-07-17 at 14 50 20 Screenshot 2023-07-17 at 14 52 23