Forum rules - please read before posting.

Hotspots tap issue on mobile

edited October 2019 in Technical Q&A

Hi

Now, to use inventory item on hotspot (touchscreen) we need 3 steps:

  • tap on the item in inventory
  • tap on a Hotspot
  • tap to use

We have option Activate Hotspots with double-tap? disabled.

Also, when you tap on a item and it sticks to finger we can see USE APPLE ON. Usually, when you hover with item over hotspot it becomes USE APPLE ON FRIDGE, but now it doesn't change.
When finger released - item just stays on a screen.

Comments

  • I shall look into it. Enabling drag-and-drop inventory should reduce it to one-tap, however.

  • I can't recreate such an issue. What is your AC version?

    Please also provide screenshots of your Settings and Cursor Managers, the properties of your Hotspot menu, and a typical Hotspot Inspector.

  • We looked into the issue.

    We use AC Menu with Unity UI Prefab and Rewired for Input.

    It looks like EventSystem.IsPointerOverGameObject() (without a parameter) does not use Input.mousePosition, but some other value, or returns a cached result. Anyway, on Touch devices when using the Rewired Standalone Input Module with the "Allow Mouse Input If Touch Supported" option turned on, EventSystem.IsPointerOverGameObject() does not always return false.
    The actual check is performed and the value returned by the method changes on TouchPhase.Ended and some other events, while does not change on TouchPhase.Began/Moved.

    So, what is going on when user tries to select an item in the Inventory and apply it to the Hotspot:

    1) Tap to select item in the inventory.

    • TouchPhase.Ended occurs on Unity UI, EventSystem.IsPointerOverGameObject() starts to return true.

    2) Tap (1-st) on Hotspot

    • TouchPhase.Began occurs outside of Unity UI, but EventSystem.IsPointerOverGameObject() still returns true, AC ignores event.
    • TouchPhase.Ended occurs outside of Unity UI, EventSystem.IsPointerOverGameObject() starts to return false.

    3) Tap (2-nd) on Hotspot

    • Works normally

    The issue not only applies to Hotspots or Inventory, in general, after interacting with Unity UI, the next Tap on the scene gets ignored.

    Perhaps disallowing mouse is not always the appropriate solution, could there be a fix in AC? Check mouse only if there are no Touch events. PlayerInteraction, PlayerMovement, something like:

    protected bool UnityUIBlocksClick ()
    {
    if (KickStarter.settingsManager.unityUIClicksAlwaysBlocks)
    {
    if (KickStarter.settingsManager.hotspotDetection == HotspotDetection.MouseOver)
    {
    if (Input.touchCount > 0)
    {
    if (Input.GetTouch(0).phase == TouchPhase.Began)
    {
    if (KickStarter.playerMenus.EventSystem.IsPointerOverGameObject(Input.GetTouch(0).fingerId))
    {
    return true;
    }
    }
    }
    else if (KickStarter.playerMenus.EventSystem.IsPointerOverGameObject ())
    {
    return true;
    }
    }
    }
    return false;
    }

  • edited November 2019

    Try the following for PlayerInteraction:

    protected virtual bool UnityUIBlocksClick ()
    {
        if (KickStarter.settingsManager.unityUIClicksAlwaysBlocks)
        {
            if (KickStarter.settingsManager.hotspotDetection == HotspotDetection.MouseOver)
            {
                #if UNITY_EDITOR
                if (KickStarter.settingsManager.inputMethod == InputMethod.TouchScreen)
                {
                    if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began)
                    {
                        if (KickStarter.playerMenus.EventSystem.IsPointerOverGameObject(Input.GetTouch(0).fingerId))
                        {
                            return true;
                        }
                    }
                    return false;
                }
                #endif
    
                if (KickStarter.playerMenus.EventSystem.IsPointerOverGameObject ())
                {
                    return true;
                }
            }
        }
        return false;
    }
    

    And this for PlayerMovement:

    protected virtual bool UnityUIBlocksClick ()
    {
        if (KickStarter.settingsManager.unityUIClicksAlwaysBlocks)
        {
            #if UNITY_EDITOR
            if (KickStarter.settingsManager.inputMethod == InputMethod.TouchScreen)
            {
                if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began)
                {
                    if (KickStarter.playerMenus.EventSystem.IsPointerOverGameObject(Input.GetTouch(0).fingerId))
                    {
                        return true;
                    }
                }
                return false;
            }
    
            if (KickStarter.settingsManager.inputMethod == InputMethod.TouchScreen ||
                KickStarter.settingsManager.movementMethod == MovementMethod.PointAndClick || 
                KickStarter.settingsManager.movementMethod == MovementMethod.StraightToCursor || 
                KickStarter.settingsManager.movementMethod == MovementMethod.Drag)
            {
                return KickStarter.playerMenus.EventSystem.IsPointerOverGameObject ();
            }
        }
        return false;
    }
    

    Note that these are becoming virtual in 1.70. If such a function needs tweaking due to a custom system such as in this case, you'll be able to do so through subclassing.

  • It works with all #if UNITY_EDITOR, #endif lines removed from both code snippets.

  • Ah, that was a typo. Should have been #if !UNITY_EDITOR, since the Input.touch code should be ignored when running in the Editor.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.