Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question Tags in Aspect

Discussion in 'Entity Component System' started by Denadan, Nov 24, 2022.

  1. Denadan

    Denadan

    Joined:
    Jun 7, 2021
    Posts:
    1
    what is correct way to use them together?

    i can filter it in foreach
    Code (CSharp):
    1. foreach(var aspect in  SystemAPI.Query<MyAspect>().WithAll<MyTag>()) { ... }
    but different tags may lead to different behaviour so should be different aspects

    ofc i can do something like that:
    Code (CSharp):
    1. public partial struct MyAspect : IAspect
    2. {
    3.   readonly RefRO<MyTag> myTag;
    4. }
    it works but throws warning of unused field and tags not have values anyway. also what to do to exclude tag?

    maybe i missing some attributes like
    Code (CSharp):
    1.  
    2. [WithAll(typeof(MyTag)]
    3. [WithNone(typeof(OtherTag)]
    4. public partial struct MyAspect : IAspect {}
    5.  
    ?
     
  2. ComradeVanti

    ComradeVanti

    Joined:
    May 22, 2015
    Posts:
    25
    I just ran into this aswell. I guess for now you just filter for tags in your queries.