Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Getting to BlobAssetReference on other entity

Discussion in 'Entity Component System' started by RoughSpaghetti3211, Aug 6, 2020.

  1. RoughSpaghetti3211

    RoughSpaghetti3211

    Joined:
    Aug 11, 2015
    Posts:
    1,694
    Im having some trouble accessing a BlobAssetReference.BlobArray from a parent entity on a different entity. Does anyone have an example on how to do this that I can look at? Thanks heaps in advance!!

    Code (CSharp):
    1.  
    2. Entities
    3.     .ForEach((Entity entity, ref MyComponentA ca, in MyComponentB cb) =>
    4.     {
    5.         // Get data from a BlobAssetReference.BlobArray on different entity or parent entity
    6.         // and do some stuff
    7.        
    8.     }).ScheduleParallel(Dependency);
    9.  
     
  2. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    3,937
    A BlobAssetReference is just a field in a component. It is no different than accessing a float3 from another entity. You just use GetComponent and dot access it.
     
  3. RoughSpaghetti3211

    RoughSpaghetti3211

    Joined:
    Aug 11, 2015
    Posts:
    1,694
    Ok so noting wrong with adding the parent entity to the child and grabbing it from there ? What is the use case for blobPrt<> To get a pointer.
     
  4. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    3,937
    It is for referencing one part of the blob from another part inside a single large blob asset. For example, you could have a node graph, and each node could contain a BlobArray of BlobPtrs to adjacent nodes.