前提:安裝jdk,安裝了android studio
1.下載unity hub
2.打開unity hub,安裝 unity
安裝記得勾選Android build support
3.在桌面上打開安裝好的unity
4.新建一個screen.具體步驟參照 (這里面是一個簡單的unity入門小教程,當(dāng)然你也需要安裝 visual studio)https://www.cnblogs.com/OctoptusLian/p/8418534.html
https://www.cnblogs.com/OctoptusLian/p/8529313.html
4.unity->prefrences->external tool,里面設(shè)置jdk 和 Android sdk 路徑
WechatIMG9.jpeg
5.左上角File —> Building Setting —> Platform 選擇 Android —> Switch Platform。
6.生成apk,單擊build,取名為Test,第一次build會讓你選擇AndroidSDK,就是剛剛安裝AndroidSDK的目錄。然后就會在你選擇的目錄下生成Test.apk文件。
到此apk編譯生成,可以運行到手機上了.
這個apk,我們用反編譯工具看看,發(fā)現(xiàn)和正常的apk沒啥區(qū)別
WechatIMG10.jpeg
打開androidmanifest 看一下,
<activity android:configChanges="density|fontScale|keyboard|keyboardHidden|layoutDirection|locale|mcc|mnc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|touchscreen|uiMode"
android:hardwareAccelerated="false"
android:label="@string/app_name"
android:launchMode="singleTask" android:name="com.unity3d.player.UnityPlayerActivity" android:screenOrientation="fullSensor">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<meta-data android:name="unityplayer.UnityActivity" android:value="true"/>
<meta-data android:name="android.notch_support" android:value="true"/>
</activity>
<meta-data android:name="unity.build-id" android:value="5d947b12-16b8-4db1-81bd-21c62793aa72"/>
<meta-data android:name="unity.splash-mode" android:value="0"/>
<meta-data android:name="unity.splash-enable" android:value="true"/>
<meta-data android:name="notch.config" android:value="portrait|landscape"/>
里面定義了一個activity 叫UnityPlayerActivity