Note: this is definitely a hack, but it adds persistent image tracking to ARKit Unity. Same idea can be applied to the Native lib as well.
Download ARKit 1.5 beta https://bitbucket.org/Unity-Technologies/unity-arkit-plugin/branch/spring2018_update
In ARSessionNative.mm, add this block of code:
extern "C" void SessionRemoveAllAnchors(void* nativeSession) {
UnityARSession* session = (__bridge UnityARSession*)nativeSession;
for (ARAnchor* a in session->_session.currentFrame.anchors)
{
[session->_session removeAnchor:a];
return;
}
}
In UnityARSessionNativeInterface.cs, add this code under SessionRemoveUserAnchor:
private static extern void SessionRemoveAllAnchors (IntPtr nativeSession);
And this under RemoveUserAnchor:
public void RemoveAllAnchors() {
#if !UNITY_EDITOR
SessionRemoveAllAnchors(m_NativeARSession);
#endif
}
Then call this from an Update or Coroutine:
UnityARSessionNativeInterface.GetARSessionNativeInterface().RemoveAllAnchors ();
When the anchor is removed, the image can be recognized once again. It's not super smooth but it definitely works.
Hope you found this useful! Let me know if you need further assistance.