using SC; using System.Collections; using System.Collections.Generic; using UnityEngine; namespace SC.Tools { public abstract class AndroidPluginBase:PersonSystemBase { protected static AndroidJavaObject CurrentActivity; protected static AndroidJavaClass UnityPlayerClass; protected List androidCallbackList = new List(); static AndroidPluginBase() { #if UNITY_ANDROID && !UNITY_EDITOR UnityPlayerClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); CurrentActivity = UnityPlayerClass.GetStatic("currentActivity"); #endif } public virtual void addListener(string listenerName, AndroidCallBackBase listener){ #if UNITY_ANDROID && !UNITY_EDITOR CurrentActivity.Call (listenerName , listener); androidCallbackList.Add(listener); #endif } public override void Awake() { base.Awake(); foreach (var item in androidCallbackList) { item.OnAwake(); } } public override void OnEnable() { base.OnEnable(); foreach (var item in androidCallbackList) { item.OnEnable(); } } public override void Start() { base.Start(); foreach (var item in androidCallbackList) { item.OnStart(); } } public override void Update() { base.Update(); foreach (var item in androidCallbackList) { item.OnUpdate(); } } public override void OnDisable() { base.OnDisable(); foreach (var item in androidCallbackList) { item.OnDisable(); } } public override void OnDestroy() { base.OnDestroy(); foreach (var item in androidCallbackList) { item.OnDestroy(); } } } }