Method ScheduleAddImageWithValidationJob
ScheduleAddImageWithValidationJob(NativeSlice<byte>, Vector2Int, TextureFormat, XRReferenceImage, JobHandle)
Asynchronously adds an image to this library.
Declaration
public AddReferenceImageJobState ScheduleAddImageWithValidationJob(NativeSlice<byte> imageBytes, Vector2Int sizeInPixels, TextureFormat format, XRReferenceImage referenceImage, JobHandle inputDeps = default)
Parameters
Type | Name | Description |
---|---|---|
NativeSlice<byte> | imageBytes | The raw image bytes in |
Vector2Int | sizeInPixels | The width and height of the image, in pixels. |
TextureFormat | format | The format of |
XRReferenceImage | referenceImage | The XRReferenceImage data associated with the image to add to the library. This includes information like physical dimensions, associated Texture2D (optional), and string name. The guid must be set to zero (Empty). A new guid is automatically generated for the new image. |
JobHandle | inputDeps | (Optional) Input dependencies for the add image job. |
Returns
Type | Description |
---|---|
AddReferenceImageJobState | Returns an AddReferenceImageJobState that can be used to query the status of the job. The AddReferenceImageJobState can be used to determine whether the image was successfully added. Invalid images will be not be added to the reference image library. |
Remarks
Image addition can take some time (for example, several frames) due to the processing that must occur to insert the image into the library. This is done using the Unity Job System. The returned AddReferenceImageJobState allows your to query for the status of the job, and, if the job completed, whether it was successful. The job state includes the JobHandle which can be used to chain together multiple tasks.
This job, like all Unity jobs, can have dependencies (using the
inputDeps
). This can be useful, for example, if imageBytes
is the
output of another job. If you are adding multiple images to the library, it is not necessary to pass a
previous ScheduleAddImageWithValidationJob(NativeSlice<byte>, Vector2Int, TextureFormat, XRReferenceImage, JobHandle)'s JobHandle
as the input dependency to the next
ScheduleAddImageWithValidationJob(NativeSlice<byte>, Vector2Int, TextureFormat, XRReferenceImage, JobHandle).
The imageBytes
must be valid until this job completes. The caller is responsible for
managing its memory. You can use the resulting JobHandle
to schedule a job that deallocates the
imageBytes
.
Exceptions
Type | Condition |
---|---|
ArgumentException | Thrown if |
ArgumentException | |
ArgumentNullException | Thrown if |
ArgumentOutOfRangeException | Thrown if |
InvalidOperationException | Thrown if the |
ArgumentOutOfRangeException | Thrown if |