Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

what is the meaning of "requiredComponents"

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

  1. huodianyan

    huodianyan

    Joined:
    Apr 21, 2015
    Posts:
    16
    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:
    365
    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:
    122
    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.
     
    ben4d85 and Zoelovezle like this.