Touch not detectable past Panel - Unity3D/Vuforia - unity3d

I have been trying to add touch event to 3D gameObject in Unity.
Previously I was not using any Canvas or Panel so by using Event Trigger and Event System I was able to add touch events to the Gameobject but then I wanted to use a UI for Application and implemented this hierarchy.
Camera
GameOBject
Canvas
Panel(Transparent)
-Buttons
Panel2
EventSystem
So if i tap a part it does not respond.
Camera does have Physics Raycaster.
Gameobjects have colliders and mesh renderers.
I want a touch input from the mobile device.
Thanks

If two Button overlap each other then the order in which camera renders top will be detected.
So try changing the hierarchy order (remember the last in the hierarchy is always top of the camera ) you can achieve which one to click

Related

Unity specific area touch input

i want to make an area in my game where i can get touch inputs from the player.
Now i get touch from all the way of the screen.
strong textI want to get from the buttom of the screen or so.
You can make an invisible UI element or GameObject and on there check if it was clicked or not. You can do this with either https://docs.unity3d.com/2018.1/Documentation/ScriptReference/EventSystems.IPointerClickHandler.html or https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnMouseDown.html

How to add a Camera to a GameObject

I am new to Unity and am working on a UI project. I want to add a Camera targeted on a GameObject in the Canvas. There is a Camera with the same hierarchy of the Canvas and when I clicked it the preview is blank but when I play the project everything is shown, including all the buttons texts images.
How does the Camera work with UI and is it possible to add a camera targeted on a GameObject?
For your main Canvas, you do not need a Camera. Please see the Unity Manual for information regarding the Canvas. Take note of the Render Mode option on the Canvas Component. If this is set to Screen Space - Overlay then you will not need a camera to view UI Items or GameObjects that are placed as children to this GameObject. It will also inherently not appear in your Camera Preview if it is located under a Canvas of this type.
If you would like to have other GameObjects show up in the Camera Preview, add them to your scene and ensure that they are not under the Canvas GameObject. Then ensure that they are in range of your Camera.
Hope this helps!

OnMouseDown event received outside camera view port, where object is not visible

An object has a collider 2D and is outside the camera viewport. Below the camera viewport to be exact.
The camera is rendering only on a portion of the screen-buffer/viewport-rect. The camera is orthographic.
The object has monobehaviour attached with OnMouseDown event declared in it.
Green is collider, white is camera viewport.
This is game view. pink is area being rendered by camera, it is taking touch event on highlighted red area.
When clicked just below the render area of the camera, the object receives OnMouseDown. which it should not because the object is not visible.
I have tried reproducing the issue on Editor with no success.
There is only one camera in the scene.
void OnMouseDown()
{
Debug.Log("Clicked");
}
It behaves correctly on Editor, means it does not take a touch in Editor. But on Windows player (build) when touched below the drawing area (viewport rect) of the camera, the button receives the event.
Why the behaviour difference between editor and player?
It should not take touch on objects outside the viewport.
Upgrading to unity version 2017.4.26 fixed the issue. it is 100% reproducible in version Unity 2017.4.5.
It is an engine issue.
Possible solutions are:
1) upgrade to unity 2017.4.26f
2) as #derHugo said in above comment "Maybe you could use OnBecameVisible and OnBecameInvisible to simply enable and disable the collider?"

unity2d button collider collide with border when character moves

I made a button that is clickable during the game playing. As I want the button have a fixed position in the main camera, I made both the main camera and the button children of the player gameObject so that the camera will follow the character while jumping or moving, everything works fine but there also a border colliders which will prevent the character moving out of the playing area. But then the collider of the button which was made intend to make the button clickable will also collide with the border which will prevent the character moving right forward. If we set the collider of the button a trigger, it seems that the button will be triggered wherever I click the mouse on the screen, that's not what I wanted.
I know maybe I could prevent this by checking if the collided object is the button or the character, but is there a better way to do that? Thanks.
For a 2D platform game, I would add a 2D user interface in a canvas over the "map" (the layer where you have the gameobjects like the character, platforms, enemies...). So the button will be always in the same place of the screen and will never collide with any gameobject of the game.
You make take some ideas from here: https://unity3d.com/learn/tutorials/topics/user-interface-ui/ui-events-and-event-triggers
Try use new UI in Unity may it fix your issue:
https://unity3d.com/learn/tutorials/topics/user-interface-ui/ui-button

unity | disable eventsystem module input for one gameobject

I have a eventsystem with 2 inputmodules (gaze (for cardboard) and touch). The gazeinput is above de touchinput, so that is going to be used by unity as main inputmodule. Now i have 1 object that i want to trigger on touchinput, but that is not working because of the gazeinput. So my question is if it is possible to disable the gazeinput just for this 1 gameobject?
EDIT: the object is a menu button, located in the bottom-right corner. It moves with the camera.
thanks
use raycast. when your camera is seeing the gameobject on which you want to use the touch input. detect that the user is looking at the camera via raycast.
Attach a script (to the camera or an empty gameobject) that has the reference of both the input modules
When the player looks at the object(detected through raycast) in which you want to use the touch input. Simply disable the gazeinput.
And when the player looks away from that gameObject enable the gazeinput