Search Unity

"two containers may not be the same (aliasing)"

Discussion in 'Entity Component System' started by PhilSA, Jul 28, 2020.

  1. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    If I make a job that has both of these at the same time:
    • [ReadOnly] ComponentDataFromEntity<Translation>
    • ComponentTypeHandle<Translation>
    ... it's gonna give me this error: "two containers may not be the same (aliasing)"

    I want to have them both in my job for reasons that would take too long to explain. So I'd like to know; is there any way to "bypass" this aliasing error, and if so, what would be the drawbacks? I'm not at all familiar with what "aliasing" entails here
     
    Last edited: Jul 28, 2020
    DragonCoder and deus0 like this.
  2. desertGhost_

    desertGhost_

    Joined:
    Apr 12, 2018
    Posts:
    260
    I believe the issue is you could be reading / writing to the same data inadvertently; the safety system does not allow this.

    I've had a similar use case before. My solution was to create a stash job that stashes the information I needed and then process that information in a second job scheduled in the same system.
     
    PhilSA likes this.
  3. deus0

    deus0

    Joined:
    May 12, 2015
    Posts:
    256
    You could add WithNativeDisableContainerSafetyRestriction onto it, if you are sure it is safe.
     
    Sirius64 and azmi_unity like this.