Search Unity

Feedback Suggestion: Attribute version of RequireSingletonForUpdate

Discussion in 'Entity Component System' started by illinar, Sep 21, 2020.

  1. illinar

    illinar

    Joined:
    Apr 6, 2011
    Posts:
    863
    Self explanatory title. An option to have this:
    Code (CSharp):
    1. [UpdateInGroup(typeof(ClientSimulationSystemGroup))]
    2. [RequireSingletonForUpdate(typeof(NetworkIdComponent))]
    3. public class ClientRcpSendSystem : ComponentSystem
    4. {
    5.     protected override void OnUpdate()
    6.     {
    7.         if (Input.GetKey("space"))
    8.         {
    9.             var req = PostUpdateCommands.CreateEntity();
    10.             PostUpdateCommands.AddComponent(req, new OurRpcCommand());
    11.             PostUpdateCommands.AddComponent(req, new SendRpcCommandRequestComponent());
    12.         }
    13.     }
    14. }
    Instead of this:
    Code (CSharp):
    1. [UpdateInGroup(typeof(ClientSimulationSystemGroup))]
    2. public class ClientRcpSendSystem : ComponentSystem
    3. {
    4.     protected override void OnCreate()
    5.     {
    6.         RequireSingletonForUpdate<NetworkIdComponent>();
    7.     }
    8.  
    9.     protected override void OnUpdate()
    10.     {
    11.         if (Input.GetKey("space"))
    12.         {
    13.             var req = PostUpdateCommands.CreateEntity();
    14.             PostUpdateCommands.AddComponent(req, new OurRpcCommand());
    15.             PostUpdateCommands.AddComponent(req, new SendRpcCommandRequestComponent());
    16.         }
    17.     }
    18. }
     
  2. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,776
    I just bump it, in case.
     
    Lukas_Kastern likes this.