指示活动或服务使用的 Unity 桥接 Java 实例。
注意:此对象由 Unity 运行时管理,因此请不要对此对象调用 AndroidJavaObject.Dispose。
using UnityEngine; using UnityEngine.Android;
public class Controller : MonoBehaviour { void Start() { var bridgeClass = AndroidApplication.unityPlayer.Call<string>("toString"); var isActivity = bridgeClass.StartsWith("com.unity3d.player.UnityPlayerForActivityOrService"); var isGameActivity = bridgeClass.StartsWith("com.unity3d.player.UnityPlayerForGameActivity"); Debug.Log($"Class for Activity: {isActivity}, Class for GameActivity: {isGameActivity}"); } }