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

How does ut.Optional work?

Discussion in 'Project Tiny' started by ER_Dolleman, Mar 25, 2019.

  1. ER_Dolleman

    ER_Dolleman

    Joined:
    Dec 10, 2018
    Posts:
    19
    I recently learned that ut.Subtractive can be used to exclude specific components in a world.forEach loop.
    https://forum.unity.com/threads/filter-components.646471/#post-4344961

    I also noticed that there is a ut.Optional function. I tried to use it in the same way like this:
    Code (JavaScript):
    1. this.world.forEach([game.Component1, game.Component2], [ut.Optional(game.Component3)], (comp1, comp2, comp3) => {
    2.     console.log(comp3);
    3. });
    This seems to work since it does iterate over the right entities, but the comp3 parameter is always undefined. What is the correct way of using this?