Search Unity

Use [GenerateAuthoringComponent] but override Convert function

Discussion in 'Entity Component System' started by zardini123, Feb 7, 2020.

  1. zardini123

    zardini123

    Joined:
    Jan 5, 2013
    Posts:
    68
    I'm using the [GenerateAuthoringComponent] tag on a IComponentData struct so I can author the data in the scene, and easily have the data transferred to its respective component. But, now because I'm using the attribute, I'm guessing the Convert function usually required by IConvertGameObjectToEntity has been automatically declared by the authoring attribute.

    Is there a way to override the Convert function generated by [GenerateAuthoringComponent]?
     
  2. zardini123

    zardini123

    Joined:
    Jan 5, 2013
    Posts:
    68
    I just realized the only way for [GenerateAuthoringComponent] to work properly if it has control of Convert, as it needs to make the components and transfer the data.

    So a replacement to my first question: Is there a way to append on logic to the auto-created Convert function?
     
  3. Lucas-Meijer

    Lucas-Meijer

    Unity Technologies

    Joined:
    Nov 26, 2012
    Posts:
    175
    No. You can however use the new dots compiler inspectie to copy paste the auto generated code, and use it as a starting point for a handwritten authoring component
     
    KwahuNashoba and Zoey_O like this.
  4. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    4,268
    Is this something that has been released? This is the first time I have heard of something like this and if I wanted to view the generated code the only method I was aware of was decompiling the assemblies.
     
  5. zardini123

    zardini123

    Joined:
    Jan 5, 2013
    Posts:
    68
    I'm also in the same boat of confusion with @DreamingImLatios. I know there is viewing generated code when it comes to Burst-compiled code, but I'm not familiar with any C# related code viewing for DOTS.