private void _teardown() { #if UNITY_IOS set_interaction_delegate_ball_did_bounce_callback(null); set_interaction_delegate_ball_did_shake_callback(null); set_connection_delegate_ball_did_change_state_callback(null); _ball_did_bounce_callback_holder = null; _ball_did_shake_callback_holder = null; #elif UNITY_ANDROID #endif }
void Awake() { #if UNITY_IOS DontDestroyOnLoad(this.gameObject); // Store the callback functions _ball_did_bounce_callback_holder = new BallDidBounceCallback(_ball_did_bounce_callback); _ball_did_shake_callback_holder = new BallDidShakeCallback(_ball_did_shake_callback); _ball_did_change_connection_state_callback_holder = new BallDidChangeConnectionStateCallback(_ball_did_change_connection_state_callback); // Set native pointers to internal callbacks set_interaction_delegate_ball_did_bounce_callback(_ball_did_bounce_callback_holder); set_interaction_delegate_ball_did_shake_callback(_ball_did_shake_callback_holder); set_connection_delegate_ball_did_change_state_callback(_ball_did_change_connection_state_callback_holder); initializer(); #elif UNITY_ANDROID DontDestroyOnLoad(this.gameObject); // First the SDK needs the activity context, so we create a reference to the UnityPlayer class. AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); if (jc == null) { Debug.Log("unable to get unity activity class"); } // Second we get a reference to the activity. AndroidJavaObject jo = jc.GetStatic <AndroidJavaObject>("currentActivity"); if (jo == null) { Debug.Log("unable to get current activity"); } else { Debug.Log("Current activity read"); } // The SDK needs to be instatiated with a reference to the activity and the Ball Listener callback interface. pluginCallback = new WRLDSAndroidPluginCallback(); pluginClass = new AndroidJavaObject("com.wrlds.sdk.Ball", new object[] { jo, pluginCallback }); pluginCallback.pluginClass = pluginClass; #else Destroy(this); #endif }
private static extern void set_interaction_delegate_ball_did_bounce_callback(BallDidBounceCallback callback);