Search Unity

  1. Unity 2019.1 is now released.
    Dismiss Notice

about lambda functions

Discussion in 'Data Oriented Technology Stack' 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:
    1,120
    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.