Skip to content

ImageTargetManager

Alexander Shubin edited this page Apr 6, 2023 · 3 revisions

You can access the ImageTargetManager through RootObject.Instance.imageTargetManager.

Wrapper for three implementations:

  • ImageTargetManagerARFoundation - ARFoundation (Android, iOS)
  • ImageTargetManagerVuforia - (Windows, Android, iOS) [currently conflicts with MRTK on Android, iOS, Editor, but should work on Hololens]
  • ImageTargetManagerEditor - (Editor)

ImageTarget can be added from the editor to the images field or programmatically at runtime.

public class ImageTargetModel – a model that describes the ImageTarget:

  • public string name; – name
  • public Texture2D texture2D; – texture
  • public float width = 1f; – width
  • public GameObject prefab; – a prefab that will be displayed when the object is tracked
  • public bool useLimitedTracking; – when enabled, the object will not disappear in situations where the image is not tracked, but its position can be predicted.

image

  • public async Task<IImageTarget> AddImageTarget(ImageTargetModel model, CancellationToken cancellationToken = default) – an asynchronous method for adding a new ImageTarget. If the ImageTarget cannot be created, the method will return null. For Editor and Vuforia, IImageTarget will be created immediately, but for ARFoundation, IImageTarget will only be created when the camera is pointed at the image (a feature of ARFoundation). If you need to cancel the creation of ImageTarget, you can use cancellationToken.
  • public void RemoveImageTarget(IImageTarget imageTarget) – a method for removing ImageTarget. ARFoundation does not have an API for removing ImageTarget from the MutableRuntimeReferenceImageLibrary, but calling RemoveImageTarget will remove the prefab, simulating the removal of ImageTarget.

image