Android handles updates from ARCore a little bit differently than ARKit, which exposes three different events for added, updated, and removed nodes. When using ARCore, these events get called whenever any changes occur, and the handler that will take care of this is the one we are about to add.
Let's add the method by going through the following steps:
- In the WhackABox.Droid project, open the Game.cs file.
- Add the OnARFrameUpdated() method anywhere in the class, as shown in the following code block:
private void OnARFrameUpdated(Frame arFrame)
{
var all = arCore.Session.GetAllTrackables(
Java.Lang.Class.FromType(
typeof(Com.Google.AR.Core.Plane)));
foreach (Com.Google.AR.Core.Plane plane in all)
{
var node =
FindNodeByPlaneId(plane.GetHashCode().ToString());
if (node == null)
{
node = new PlaneNode
{
PlaneId = plane.GetHashCode...