Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is UnityPlayerActivity, UnityPlayerNativeActivity, UnityPlayerProxyActivity?

I'm so confused with unity classes.jar that contain this three files: UnityPlayerActivity, UnityPlayerNativeActivity, UnityPlayerProxyActivity.

  1. Can you help me to understand how they work? And what function they have?

  2. Why Android can find my plugin if I set the activity to UnityPlayerActivity on manifest via unity editor?

like image 910
Chrisk8er Avatar asked Nov 04 '15 09:11

Chrisk8er


1 Answers

ON ANDROID

Activities on Android, are like main() function - it's an entry point. It represents a single screen with a user interface just like window or frame where user interacts with an app.

Check it: https://www.tutorialspoint.com/android/android_acitivities.htm https://developer.android.com/reference/android/app/Activity.html


Native activities are activities that will be implemented purely in native code. Android NativeActivity https://developer.android.com/reference/android/app/NativeActivity.html


On UNITY:

UnityPlayerActivity - extends Android's Activity.

(deprecated) UnityPlayerNativeActivity - extends NativeActivity.

(deprecated) UnityPlayerProxyActivity - used as a proxy layer to switch automatically between NativeActivity and Activity. And chose one of them.


Starting from Unity 5, the UnityPlayerActivity is a default calling class.

When UnityPlayerActivity is called, it launches UnityPlayer activity which is nothing more than a FrameLayout that holds the SurfaceView where-with the help of OpenGL the actual game or app created in Unity will be drawn later on.

https://android.jlelse.eu/unity-and-android-connecting-the-dots-6368b31e86c5 - highly recommended this article for information how Unity connects to Android.


UnityPlayerNativeActivity was default activity back in Unity 4.5 and 4.6. But has bad implementation issues, so again switched to Activity again.

To check differences between Activity and NativeActivity, check the differences on Android documentation. And next interesting articles:

http://answers.unity3d.com/questions/853012/regarding-unitys-main-android-activity.html

Native Activity vs SDK Activity in terms of U.I


UnityPlayerProxyActivity - is a proxy and was used in Unity 3.x to switch between NativeActivity and Activity depending on device capabilites. But now, it's not used anymore.

https://forum.unity.com/threads/androidmanifest-com-unity3d-player-unityplayerproxyactivity.285973/

like image 180
ahmetson Avatar answered Nov 10 '22 00:11

ahmetson