Search Unity

Question UnityPlayer class public methods and properies

Discussion in 'Documentation' started by dbu9, Jan 4, 2023.

  1. dbu9

    dbu9

    Joined:
    Jan 2, 2023
    Posts:
    8
    To get player's android activity we use the following code:

    Code (CSharp):
    1. AndroidJavaClass playerClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
    2. AndroidJavaObject activity = playerClass.GetStatic<AndroidJavaObject>("currentActivity");
    The code uses currentActivity public property of UnityPlayer class.
    Is there documentation which describes all public properties and methods of UnityPlayer class?
     
  2. dbu9

    dbu9

    Joined:
    Jan 2, 2023
    Posts:
    8
    Well, I dropped ~/Unity/Hub/Editor/2020.1.17f1/Editor/Data/PlaybackEngines/AndroidPlayer/Variations/mono/Release/Classes/classes.dex into Android studio to analyze the file and then looking at bytecode of a member function i can understand if it's public, protected or private.
    Here is an example:

    classes.png

    Is there a better way to know about UnityPlayer?
     
  3. JuliusM

    JuliusM

    Unity Technologies

    Joined:
    Apr 17, 2013
    Posts:
    835
    Currently we don't have documentation for our java APIs. We have plans to provide it in the future, but it will take a while.

    You could check the Unity activity source file (in Unity install location, or by exporting an Android project) to see how activity interacts with the Unity player and what methods are called there. In addition to that, we have this documentation page https://docs.unity3d.com/Manual/UnityasaLibrary-Android.html providing information on how to integrate Unity into Android applications. Hopefully that will be helpful to you.
     
    dbu9 likes this.