BlobObjectExtensions
Extension methods for a BlobObject that you reference with a UnityObjectRef.
Read time 1 minuteLast updated 3 hours ago
Definition
- Type: Class
- Namespace: Unity.Animations
- Assembly: UnityEngine.AnimationCoreModule
public static class BlobObjectExtensions
Remarks
Use BlobObjectExtensions.AcquireReference when you hold the BlobObject as a UnityObjectRef<T>, for example in a component in the Entities package. The method returns a BlobObjectReference<T> that you dispose when you finish with it. To store data in the object, and for the type and version rules of the data, refer to .
BlobObject.SetBlobAssetThe following example uses the , , and namespaces. It reads a custom blob through a to a , and returns 0 if the reference is invalid.
Unity.AnimationsUnity.EntitiesUnityEngineUnityObjectRefBlobObjectAdditional Resources: BlobObject, BlobObjectReference<T>
Examples
// This example reads the marker times of a BlobObject that a component holds as a UnityObjectRef.// A custom blob type can hold only unmanaged data, such as values and BlobArray fields.public struct MarkerTable{ public BlobArray<float> Times;}public static float SumMarkerTimes(UnityObjectRef<BlobObject> objectRef){ const int version = 1; // The reference is invalid if the object is missing, empty, or stores another version of the data. using BlobObjectReference<MarkerTable> reference = objectRef.AcquireReference<MarkerTable>(version); if (!reference.IsValid) { return 0f; } ref MarkerTable table = ref reference.Value; float sum = 0f; for (int i = 0; i < table.Times.Length; ++i) { sum += table.Times[i]; } return sum;}
Static Methods
Method | Description |
|---|---|
| AcquireReference | Acquires a reference to the blob data stored in the object that a UnityObjectRef points to. |