Search Unity

  1. Unity 2019.1 beta is now available.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We're looking for insight from anyone who has experience with game testing to help us better Unity. Take our survey here. If chosen to participate you'll be entered into a sweepstake to win an Amazon gift card.
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Unity 2018.3 is now released.
    Dismiss Notice
  6. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

about lambda functions

Discussion in 'Entity Component System and C# Job system' started by laurentlavigne, Nov 30, 2018.

  1. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    2,012
    So this is the new way. Why not this instead?
    Code (CSharp):
    1. void OnUpdate(ref Spawner spawner, in Position position)
    2. {
    3. }
     
  2. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    937
    Who is the caller of OnUpdate with custom parameters? If it is called "from below" then listed types would have to be in the class name's generic (similar to IJobProcessComponentData) so the caller knows what OnUpdate to call, or we have to use reflection on the class to find any method named exactly OnUpdate (because not using override) and extract argument parameters. That might be error prone, and we could have only one set of in out data to work for one system.

    The lambda design's "ForEach" works more like GetComponentGroup, where the type specified would be registered as a reader writer with the system on the first call (at runtime). And it would allow you to do multiple of ForEach.
     
    laurentlavigne likes this.
  3. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    2,012
    Convinced!
    Thanks.