N
N
nuclear_kote2019-11-05 01:52:35
Unity
nuclear_kote, 2019-11-05 01:52:35

How to correctly handle clicking on a UI component in unity ECS?

I want to make a container with a list of playable characters. By clicking on the character, the character should become active.
Created a component containing a character and an activity flag:

public struct PartyCellComponent : IComponentData {

        public PlayableCharacter playableCharacter;
        public bool active;

    }

Created entity:
[RequiresEntityConversion]
    public class PlayerCellEntity  : MonoBehaviour, IConvertGameObjectToEntity {
     [SerializeField]private PlayableCharacter playableCharacter;
     public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem) {
            var data = new PartyCellComponent {
                playableCharacter = playableCharacter,
                active = false
            };
            dstManager.AddComponentData(entity, data);
        }
}

Created a system:
public class PartyCellSystem : ComponentSystem {
    protected override void OnUpdate() {

    }
}

Question: how to correctly change the active flag when clicking on an entity ?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question