Search Unity

what is the meaning of "requiredComponents"

Discussion in 'Project Tiny' started by huodianyan, Mar 15, 2019.

  1. huodianyan

    huodianyan

    Joined:
    Apr 21, 2015
    Posts:
    13
    Code (JavaScript):
    1. @ut.requiredComponents(Comp1, Comp2)
    2. export class DoSomethingSystem extends ut.ComponentSystem {
    3.     OnUpdate(): void {
    4.         console.log("update!");
    5.     }
    6. }
    I think this system will enable and run OnUpdate() when there are entities with Comp1 and Comp2 in the world, but the system runs every frame even though there is no Comp1 or Comp2 in the world.

    What is the real meaning of the decorator "requiredComponents"?
     
  2. sniffle63

    sniffle63

    Joined:
    Aug 31, 2013
    Posts:
    84
    Also was wondering this,
    I thought it would return an error/warning if something had one of the required but not the rest. But i cant seem to get it to do anything
     
    Zoelovezle likes this.
  3. raymondyunity

    raymondyunity

    Unity Technologies

    Joined:
    Apr 30, 2018
    Posts:
    65
    The "requiredComponent" decorator does not work. It is a proof of concept and would throw errors if the system did not include those components.

    Apologies for the confusion.
     
    Zoelovezle likes this.