ImageTargetManager - WEKIT-ECS/MIRAGE-XR GitHub Wiki
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;
– namepublic Texture2D texture2D;
– texturepublic float width = 1f;
– widthpublic GameObject prefab;
– a prefab that will be displayed when the object is trackedpublic bool useLimitedTracking;
– when enabled, the object will not disappear in situations where the image is not tracked, but its position can be predicted.
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 usecancellationToken
.public void RemoveImageTarget(IImageTarget imageTarget)
– a method for removing ImageTarget. ARFoundation does not have an API for removing ImageTarget from the MutableRuntimeReferenceImageLibrary, but callingRemoveImageTarget
will remove the prefab, simulating the removal of ImageTarget.