Пример #1
0
        protected override void ConvertComponent(UnityEngine.UI.Selectable unityComponent, Entity entity, RectTransformToEntity rectTransformToEntity, Dictionary <UnityEngine.Object, Entity> assetToEntity, EntityManager mgr)
        {
            mgr.AddComponent(entity, typeof(DotsUI.Input.Selectable));
            var    colors = unityComponent.colors;
            Entity target;

            if (!rectTransformToEntity.TryGetValue(unityComponent.targetGraphic?.rectTransform, out target))
            {
                target = entity;
            }
            mgr.AddComponentData(entity, new DotsUI.Input.SelectableColor()
            {
                Normal         = colors.normalColor.ToFloat4(),
                Hover          = colors.highlightedColor.ToFloat4(),
                Pressed        = colors.pressedColor.ToFloat4(),
                Selected       = colors.selectedColor.ToFloat4(),
                Disabled       = colors.disabledColor.ToFloat4(),
                TransitionTime = colors.fadeDuration,
                Target         = target
            });

            var pointerInputReceiver = GetOrAddComponent <Input.PointerInputReceiver>(mgr, entity);

            pointerInputReceiver.ListenerTypes |= Input.PointerEventType.SelectableGroup;
            mgr.SetComponentData(entity, pointerInputReceiver);
        }
Пример #2
0
        protected override void ConvertComponent(TMP_InputField unityComponent, Entity entity, RectTransformToEntity rectTransformToEntity, Dictionary <UnityEngine.Object, Entity> assetToEntity, EntityManager mgr)
        {
            mgr.AddComponentData(entity, new DotsUI.Input.KeyboardInputReceiver());
            mgr.AddBuffer <DotsUI.Input.KeyboardInputBuffer>(entity);
            Entity target = default;

            if (!rectTransformToEntity.TryGetValue(unityComponent.textComponent?.rectTransform, out target))
            {
                target = entity;
            }
            Entity placeholder = default;

            rectTransformToEntity.TryGetValue(unityComponent.placeholder.rectTransform, out placeholder);
            mgr.AddComponentData(entity, new DotsUI.Controls.InputField()
            {
                Target      = target,
                Placeholder = placeholder
            });
            mgr.AddComponentData(entity, new DotsUI.Controls.InputFieldCaretState()
            {
                CaretPosition = 0,
            });
        }
Пример #3
0
        protected override void ConvertComponent(UnityEngine.UI.InputField unityComponent, Entity entity, RectTransformToEntity rectTransformToEntity, Dictionary <UnityEngine.Object, Entity> assetToEntity, EntityManager commandBuffer)
        {
            commandBuffer.AddComponentData(entity, new DotsUI.Input.KeyboardInputReceiver());
            commandBuffer.AddBuffer <DotsUI.Input.KeyboardInputBuffer>(entity);
            Entity target = default;

            if (!rectTransformToEntity.TryGetValue(unityComponent.targetGraphic?.rectTransform, out target))
            {
                target = entity;
            }
            commandBuffer.AddComponentData(entity, new DotsUI.Controls.InputField()
            {
                Target = target
            });
            commandBuffer.AddComponentData(entity, new DotsUI.Controls.InputFieldCaretState()
            {
                CaretPosition = 0
            });
        }