Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Burstable BlobString Compare

Discussion in 'Burst' started by Soaryn, Dec 26, 2019.

  1. Soaryn

    Soaryn

    Joined:
    Apr 17, 2015
    Posts:
    328
    So I am attempting to compare two different blobs' strings together, and was hoping to do this in a bursted job; however, the compiler is not allowing me to utilize the BlobString due to the MayOnlyLiveInBlobStorage attribute. Note, I don't need to mutate the string, merely check if it matches a constant. My attempt revolved around creating a BlobSingletonComponent upon System creation for the context I am looking for, then try to check equals to the other when in the job.

    Code (CSharp):
    1. ref var blobRef = ref component.BlobReference.Value;
    2. ref var contextBlobRef = ref contextBlob.Value;
    3.  
    4. ref var context = ref blobRef.Context;
    5. ref var context2 = ref contextBlobRef.Context;
    6.  
    7. if (context2.Equals(context)) { }