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

Resolved Component doesn't get value from authoring script

Discussion in 'Entity Component System' started by ApocalypticSharksStudio, Oct 7, 2023.

  1. ApocalypticSharksStudio

    ApocalypticSharksStudio

    Joined:
    Mar 5, 2020
    Posts:
    4
    Hi. Just started with DOTS and met this problem.
    This is my component:
    Code (CSharp):
    1. public struct FartManMoveInputComponent : IComponentData
    2. {
    3.     public float fartPower;
    4.     public int fartPowerMuliplyer;
    5. }
    6.  
    7. public class FartManMoveInput : MonoBehaviour
    8. {
    9.     public float fartPower;
    10.     public int fartPowerMuliplyer;
    11. }
    12.  
    13. public class FartManMoveInputBaker : Baker<FartManMoveInput>
    14. {
    15.     public override void Bake(FartManMoveInput authoring)
    16.     {
    17.         Entity entity = this.GetEntity(TransformUsageFlags.Dynamic);
    18.  
    19.         AddComponent(entity, new FartManMoveInputComponent{
    20.             fartPower = authoring.fartPower,
    21.             fartPowerMuliplyer = authoring.fartPowerMuliplyer
    22.         });
    23.     }
    24. }
    And when I input fartPowerMuliplyer value into FartManMoveInput script it does not translates to component value:

    2023-10-07_16-06-37.png 2023-10-07_16-07-33.png

    What I do wrong?

    p.s. fartPower works well
     
  2. ApocalypticSharksStudio

    ApocalypticSharksStudio

    Joined:
    Mar 5, 2020
    Posts:
    4
    Component works well. I should have mentioned this property when I do SetSingleton...