0
\$\begingroup\$

I have a fully implemented game in a scene, which relies entirely on processed interactions using the Enhanced Touch API in Unity. I have called this script, which grabs Touch input from the screen, TouchScreenManager.cs, and have attached it to the camera.

This is designed to monitor taps/swipes/drags, and then using events/delegates, broadcasts it out to any other classes that will respond to it.

I am now designing a UI that will sit over the game. As part of the UI, I may need to implement items like scroll bars, buttons, etc.

I could work out a way to speak to these items manually, but what happens when I add a canvas is that the Event System holds a component called "Input System UI Input Module" which uses bindings, etc. to relay basic interactions with my screen.

My question is: will it cause issues, specifically duplicate events, memory issues/leaks, poor optimization, etc. if I choose to use the Input System UI Input Module for canvas-based events, and then use the TouchScreenInputManager for events like swipes, drags, and other specific interactions with the game itself?

The issue is that if I choose to go with my own manager, I would have to figure out how to manually relay Enhanced Touch events to these UI components, and I don't see any documentation anywhere on how to easily/clearly do that. For example, if I wanted to move the scroll bar using my Enhanced Touch-based implementation, I would have directly speak to Scroll Rect, move the bar manually, etc.

\$\endgroup\$
4
  • \$\begingroup\$ I think the best way to know for sure would be to build a test. If you decide you do need to replace the built-in input module, it's set up in such a way that you can substitute your own custom version, as I show in this answer. \$\endgroup\$
    – DMGregory
    Commented Jan 20, 2023 at 13:50
  • \$\begingroup\$ Thanks. Is there any sense of what is "best practice" - is using EnhancedTouch and the UI input module together discouraged for any reason? Reading the docs, I now understand the Enhanced Touch API as designed to detect/process events at a higher-level of granularity, and cannot be used in combination with InputAction, but can be used side by side. \$\endgroup\$ Commented Jan 20, 2023 at 14:16
  • \$\begingroup\$ I'm working from the same docs you are. Sadly, "best practices" are often not as well known or documented as we might expect or hope for in games - which is why I recommend testing it yourself as the best way to get an evidence-based answer quickly. \$\endgroup\$
    – DMGregory
    Commented Jan 20, 2023 at 14:19
  • \$\begingroup\$ Thanks for your help! \$\endgroup\$ Commented Jan 20, 2023 at 14:20

0

You must log in to answer this question.

Browse other questions tagged .